page_load and event handler for a radiobutton

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hello!

In the code-behind file I have this event handler
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
InitPositionRole();
}
}

I have also four event handler in the code-behind file see below. One for
each radio button. All four are in the same Group.
When I change the radio button the event handler is called.

Now to my question. What seems strange here is that the event hadler
Page_Load is called before the event handler for the
radio_button. I have thought that the Page_Load should be called as the last
event handler.
For example if I change the radio button from worker radiobutton to
bossButton the following happen.
1. Page_load will be called.
2. Event handler bossButton_CheckedChanged is called

So can somebody explain why the Page_Load is called as the first event
handler ?

protected void workerButton_CheckedChanged(object sender, EventArgs e)
{
InitPositionRole();
}
protected void bossButton_CheckedChanged(object sender, EventArgs e)
{
positionRole.Items.Clear();
positionRole.Enabled = true;
positionRole.Items.Add("General Manager");
positionRole.Items.Add("Project Manager");
}
protected void vpButton_CheckedChanged(object sender, EventArgs e)
{
positionRole.Items.Clear();
positionRole.Enabled = true;
positionRole.Items.Add("VP Sales");
positionRole.Items.Add("VP Marketing");
positionRole.Items.Add("VP Production");
positionRole.Items.Add("VP Human Resources");
}
protected void presidentButton_CheckedChanged(object sender, EventArgs e)
{
positionRole.Items.Clear();
positionRole.Enabled = false;
}
 
I have thought that the Page_Load should be called as the last
event handler.

It is late in the cycle, but specific event handlers are called after
Page_Load(). This of it this way: You are "loading" the page into memory to
be sent and the event handlers can alter that "load" before it is sent to
the client.

Peace and Grace,

--
Gregory A. Beamer (MVP)

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Back
Top