Materpage page_load event fired after content page_load?

R

rockdale

Hi,

I have a masterpage and on the page_load event I Populate my mainmenu
from database.

I the page_load event of my content, I am trying to programmly select
the menuitem that represent current content page, but as you know, the
page_load event is fired backward, the content page_load fires first
then followed by the master page page_load, I could not get the
mainmenu in the content page( have not been initialized since
masterpage's page_load have not been fired).

Is there a way to workaround? e.g. put the programmly select menuitem
into another event instead in page_load?


attached is my pseudocode:

MasterPages


protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
PopulateMainMenu();
}
}


Content Page
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{

Menu mMain = (Menu)this.Master.FindControl("menuMain");
mMain.Items[0].Selected = true;

}
}




Thanks a lot
-rockdale
 
G

Guest

How about using the Init event. Since the MasterPage is really a child
control inside the content page, it's Init eventhandler will fire before the
Page's Init eventhandler.
Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top