I have a case like below.
protected void Page_Load(object sender, EventArgs e)
{
if (SomeCheck())
{
// Block all other events from happening
}
}
protected void Button1_Click(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
}
protected void Button3_Click(object sender, EventArgs e)
{
}
//..
//..
// Other Event Handlers
//..
//..
where I have multiple event handlers like Button clicks here (in example above) and have a Page_Load
where I want to check something and on basis of that check I want to block other events from happening.
How can I do this? Am I using right event here or should I do this check on Pre_render
or something else?
UPDATE
I actually want a solution where I won't have to do any extra code or worry about the check every time I add a new event handler checking for bool variable on every event handler will became tough in code maintenance soon.