Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Materpage page_load event fired after content page_load?

Reply
Thread Tools

Materpage page_load event fired after content page_load?

 
 
rockdale
Guest
Posts: n/a
 
      11-16-2006
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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      11-16-2006
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

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




"rockdale" wrote:

> 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
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Page_Load event not fired Alfons Puig ASP .Net 5 05-25-2011 10:19 AM
Embedded <divs> with events: How to prevent the parent div's eventfrom being fired when the embedded div's event is fired? Num GG Javascript 2 11-17-2008 08:56 PM
HOWTO determine in content page page_load if masterpage fired post =?Utf-8?B?Yl9hc3AubmV0?= ASP .Net 0 04-18-2007 12:56 PM
HOWTO determine in content page page_load if masterpage fired post =?Utf-8?B?YmVycnkubW9yZ2Fu?= ASP .Net 0 04-17-2007 05:16 PM
Page_load event cannot be fired =?Utf-8?B?bGlt?= ASP .Net 1 03-07-2004 12:32 PM



Advertisments