EDIT: for those who come here with a similar problem, now i know this was a BAD IDEA.
hi,
I have something like this:
bool preventEvents;
protected void Page_Load(object sender, eventargs e)
{
preventEvents = doSomeValidation();
}
protected void Button1_Click(object sender, EventArgs e)
{
if (preventEvents) return;
// ...
}
protected void Repeater1_DataBound(object sender, EventArgs e)
{
if (preventEvents) return;
// ...
}
The problem is that I have A LOT of events on the page.
Is it possible to just cancel all further events without adding the “if” line on every method?
EDIT:
got some interesting answers (thanks to everyone) but not what i was looking for, maybe i should be more specific:
given some condition, is it possible to skip all events after Page_Load and just jump to the rendering, without manually removing/mapping each event?
You can’t “jump ahead” to the rendering because there aren’t any conditionals in
ProcessRequestMainto allow for it. The only option is to hack the event handlers of the relevant controls.Utility extension method for completeness: