473,322 Members | 1,232 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Materpage page_load event fired after content page_load?

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

Nov 16 '06 #1
1 2939
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

Nov 16 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Stevie_mac | last post by:
It might be me but... I dont seem to get a Page_Load event when a opening an ASPX in an iFrame. I do geta Page_Load event when an item on the ASPX (inside the iFrame) is clicked but then...
4
by: Alfons Puig | last post by:
Some pages (not all the pages, but I can't observe differences) opened from javascript via window.showModalDialog() doesn't fire the codebehind Page_Load event the second (and further) time it is...
14
by: V. Jenks | last post by:
I'm a little rusty having not touched .NET for 6 months and I can't remember why Page_Load is happening twice in this code: private void Page_Load(object sender, System.EventArgs e) {...
4
by: Seraph | last post by:
Again, I'm rather new here, so if I fail to follow any etiquette, please forgive me and let me know what I've done wrong, but I think this might interest quite a few people. One of my colleaques...
0
by: Joergen Bech | last post by:
Scenario: One editnews.aspx page used for editing various types of news, e.g. editnews.aspx?NewsType=Business editnews.aspx?NewsType=Fans Trouble is: There is a combobox on this page, which...
12
by: Nathan Sokalski | last post by:
What is the difference between the Page_Init and Page_Load events? When I was debugging my code, they both seemed to get triggered on every postback. I am assuming that there is some difference,...
4
by: Bart | last post by:
Hi, I have a menu on my master page. When I click on a menu item the state is reset after the page is redirected to the NavigateURL. How can fix this? Thanks Bart
0
by: =?Utf-8?B?YmVycnkubW9yZ2Fu?= | last post by:
I want to bypass my content page's page_load event when the postback is caused by a control from my masterpage, doing something like this from my content page's page_load handler: Private Sub...
2
by: Michal Valent | last post by:
I would like to fire some custom server control event before Page_Load event like this (from the trace of an aspx page) : Trace Information Category Message From First(s) From Last(s) aspx.page...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.