473,626 Members | 3,119 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(objec t sender, EventArgs e)
{
if (!Page.IsPostBa ck)
{
PopulateMainMen u();
}
}
Content Page
protected void Page_Load(objec t sender, EventArgs e)
{
if (!Page.IsPostBa ck)
{

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

}
}


Thanks a lot
-rockdale

Nov 16 '06 #1
1 2958
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(objec t sender, EventArgs e)
{
if (!Page.IsPostBa ck)
{
PopulateMainMen u();
}
}
Content Page
protected void Page_Load(objec t sender, EventArgs e)
{
if (!Page.IsPostBa ck)
{

Menu mMain = (Menu)this.Mast er.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
3968
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 IsPostBack=False by now!. The ASPX is opened via client side script (into an iFrame) inside a .HTM file (as ASPX postback causes problems in a modal internet explorer dialog if not in an iFrame!) Anyone know how to get around this - i need to...
4
3360
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 opened from the same window. If I change the IE configuration of the temporary internet files to check new versions every time the page is called then the event is fired. However it is not an acceptable solution. Thanks.
14
13104
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) { //existing session? if (Session == null) { //save local empty order object this._newOrder = Orders.Initialize();
4
3968
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 was endeavoring to create a custom user control to make things a bit simpler, but she noticed that her Page_Load eventhandler was firing twice. So after long hours of research and experimentation, I stumbled upon, imho, is quite the discovery. ...
0
942
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 is being initialized in the Page_Load event (If Not Page.IsPostBack Then ...). For one type, 10 items might be loaded into the box. For another, maybe 20.
12
17382
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, and I would like to know what it is so that I can take advantage of it in my code. Thanks. -- Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
4
1633
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
1515
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 Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles page.Load If NOT sender.ThisEventWasFiredFromTheMasterPage then 'process normally end if
2
2734
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 Begin PreInit aspx.page End PreInit 5,38454603734274E-05 0,000054 aspx.page Begin Init 8,96405962016187E-05 0,000036 aspx.page End Init 0,00072941040948794 0,000640 aspx.page Begin InitComplete 0,000772971258380746 0,000044
0
8262
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8196
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8701
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5571
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1507
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.