Master page's "Load" event is later than content page's ?

Example:
1. Add a label to master page, set its "text" attribute to nothing.
2. In master page's page load event, assign "hello" to label1.text
3. In content page's page load event:

Response.write (   ctype(master.FindControl("label1"),label).text   )
it will be nothing.

4. In content page,  add a button named button1, in button1's click event, copy the upper sentence,
it will write "hello".

so , master page's load event it later than content page's ?  If I need the result of master page's load event
in content page's load event, how should I do ?

Thanks!

0
Moosdau
5/17/2007 9:04:32 AM
asp.net.navigation-controls 13714 articles. 0 followers. Follow

2 Replies
964 Views

Similar Articles

[PageSpeed] 13

You can not get to any of the results from the master Page_Load event in the content Page_Load event, you have to place the code that you want to perform after the master Page_Load in an event that is executed later in the life cycle.

You could put the things you today have in the content Page_Load into an eventhandler for the LoadComplete or PreRender events of the content page. The LoadComplete event occurs after both the content and master Page_Load events.

    protected override void OnLoadComplete(EventArgs e)
    {
        Debug.WriteLine("OnLoadComplete");
        base.OnLoadComplete(e);
    }

    protected override void OnPreRender(EventArgs e)
    {
        Debug.WriteLine("OnPreRender");
        base.OnPreRender(e);
    }

 

Best regards,
Per Salmi 


Per Salmi, Software Developer .NET Technologies
PerSalmi.NET
0
persa
5/17/2007 10:56:26 AM

 Thanks for your solution, but I've received another easier way from other person:
because master page's Page_Init event is earlier than content page's Page_Load event,
so just put the code of master page's Load event to Init event will be ok.

 

persa:

You can not get to any of the results from the master Page_Load event in the content Page_Load event, you have to place the code that you want to perform after the master Page_Load in an event that is executed later in the life cycle.

You could put the things you today have in the content Page_Load into an eventhandler for the LoadComplete or PreRender events of the content page. The LoadComplete event occurs after both the content and master Page_Load events.

    protected override void OnLoadComplete(EventArgs e)
    {
        Debug.WriteLine("OnLoadComplete");
        base.OnLoadComplete(e);
    }

    protected override void OnPreRender(EventArgs e)
    {
        Debug.WriteLine("OnPreRender");
        base.OnPreRender(e);
    }

 

Best regards,
Per Salmi 

0
Moosdau
5/18/2007 7:21:05 AM
Reply:

Similar Artilces:

How to set a Master Page's control's property through content page on a postback event?
Hi all, i m using a master page in my application. i have a panel on master page and a tab container with three tab panels on content page. i want to set/change  the visibility of the panel control when the tab is changed on the content page. By default the panel is invisible. To implement this i executed the following steps: 1. Set AutoPostBack of tacontainer to true 2. Wrote an event handler for ActiveTabIndexChanged event of the tab container 3 Wrote the following code on Tab changed event   if (TabContainerEmpPerformance.ActiveTabIndex == 1) { ...

Problem to use TreeView Control in a 'content page' This Error Occur "Only Content controls are allowed directly in a content page that contains Content controls."
hi I am trying to use the TreeView Control inside the content page (Page that has a master page is a content page). On compiling the project I got the following ASP.Net runtime error: "Only Content controls are allowed directly in a content page that contains Content controls."B@b@R J Issue resolved. I was putting script tag in the content page that is not allowed. when remove the script from content page problem is resolved.B@b@R J...

Subtitle of "What's New" video on Firefox 13 "What's New" Page
I'd seen lots of subtitle improvements on "What's New" video of Firefox 13 on Amara stayed in the draft status and wait for approve. Is there anybody follow the revision of movie on following change? Their must be problems that we showing the subtitled on "what's new" page with Amara UI, allowed peoples to improve it directly with Amara, but no mention about that they need to wait for someone's review and approve. We just can't make contributor wondering why the subtitled stay on draft for life long time. Also is there anyone who watch behind the A...

"Internal Master page" 's Page_Load event doesn't fired?
Hi, all:   I have a problem: master page 2  is a content page of master page 1 , a page then is master page 2's content page. but during run time, after leaf page's Page_Load,  master page 1 's Page_Load will be fired, master page2 's page_Load ( and page_init , too) doesn't execute at all. why ? thanks ~ Hi, You used the nested master page right? But I test the nested master page on my local machine, the internal master page's page_load event can be fired, below is my nested master page code: 1, the outer master page: <%@ Master Language=&q...

what's the different from "<page src="">" and "<page codeBehind="">"
what's the different from "<page src="">" and "<page codeBehind="">" Thank YOU how to make session' life longer? Thank You This very question was asked only 5 days ago. Searching the forums would have yielded the answer you require. However, see this thread. Steven BeyRecursion: see Recursion You can set a new value for the Session Timeout in your web.config file. Or, you can do it in a page through this property: Session.Timeout Note that if you choose the second method, the timeout will only be modified on this page,...

Master Page's Page Load firing twice on events called from other Page events
I have numerous pages tied to my MasterPage that controls 2 Always visible extenders for User Reminders and a Counter. I would like them to only fire on a Page_Load once, not twice. I have read a million posts about AutoEventWireupset to false, but on all my pages it is set to true and on those pages the events only fire once. The Master page is giving me problems on events firing twice. Any suggestions? here is some code... protected void Page_Load(object sender, EventArgs e) {if (!Page.Master.IsPostBack) {  I call 2 stored procedures here that should only fire once on a Page_Lo...

User Control in Master page raises "clicked" event...how to subscribe to this event in "nested" Master page??
I have a custom user control with several LinkButtons that serve as a common menu for all my pages.  Within this user control, I created a delegate and a custom event...and raise a "clicked" event whenever one of the LinkButtons is clicked. I added this user control to a Master page, then subscribed to that "clicked" event in the Page_Load.  The subscribed event handler within this Master page works fine. My problem is...I created a "nested" Master page from the Master page above, and want to subscribe to the original user control...

Wired's Vista "Do's" Have Some Major "Don'ts"
Wired has an article up about how to speed up Vista. While they have a couple OK tips in there, there are a couple of suggestions that caught my attention as colossally BAD. I tried to edit the wiki page to reflect this, but I was rebuffed by the original author. So much for community contributions. http://www.windows-now.com/blogs/robert/archive/2008/02/27/wireds-vista-dos-have-some-major-donts.aspx -- "Never drive faster than your ANGEL can fly" In grc.techtalk, on Fri, 14 Nov 2008 17:32:04, paradoX wrote: >Wired has an article up about how to speed up Vist...

Deleting "to's" and "from's" on emails
Name: Rae McFarland Email: larryatmacsmachinedotcom Product: Firefox Summary: Deleting "to's" and "from's" on emails Comments: There doesn't seem to be a way to edit and email and then forward it. Some people send something I'd like to forward, but there's a whole page of previous mailing addresses. I'd like to delete them before forwarding. I've tried and the whole email gets deleted. Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16 From URL: http://hendrix.mozi...

Suggestion for Steve "How do we tell what's current & what's obsolete?" Can you add dates to your pages
Steve, We all appreciate your work and respect the honesty and integrity of what you do. This suggestion might help some of us who visit your site occasionally, but are not there everyday. And for people like me who have discovered your site only relatively recently, it would be a big help. The problem: How to tell if an item is still an active issue and whether it applies to my OS & machine. Details: As I browse the site I see a lot of interesting items. But I have no way of telling when they were developed, whether the item is still an issue that I need to address o...

Hook up to a control's event located on the Master Page from the Content Page PLEASE HELP
I have a master page with a button, and I what to hook the button click event on the content page I allready tried this example http://fredrik.nsquared2.com/viewpost.aspx?PostID=328&showfeedback=true but in vb it doesn't work. Thank you ALL. Master Page Code: Public Event OnbtnGrava_Click As EventHandler Protected Sub btnGrava_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGrava.Click RaiseEvent OnbtnGrava_Click(sender, e) End Sub Content Page code: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim mpButton ...

Apple's "One to One" page won't load in Firefox 3.5
Name: Jeff Joslin Email: joslindotjeffatgmaildotcom Product: Firefox Summary: Apple's "One to One" page won't load in Firefox 3.5 Comments: I can't get on the Apple "one to one" page with the new 3.5 software update. Here is a link: http://onetoone.apple.com/WebObjects/RRSPortal.woa/wa/home Browser Details: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5 From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this feedback but if you wish to provide ...

Master/Content Pages and ScottGu's "Atlas Keynote Walkthrough" Blog post
When I went through the Atlas Hands-on-Labs, they suggested using a Master/Content page model so that Atlas script declarations could be shared across pages.When I attempted to port ScottGu's Atlas Keynote demo to use a Master/Content page model, I found that the onSearchComplete JavaScript function (below) failed because when the page's HTML is formed from the Master Page, Content Page, and Atlas emitted JavaScript/HTML, the element id "searchResults" of the "atlas:ListView" element is changed to "ctl00_Main_searchResults"function onSearchComplete(results) {    &nbs...

Label control's text doesn't appear to be set (in the page which has a user control )when trying to update the text property in the FormView's ItemUpdated event
Hi There,I have a user control which hosts a formview control, gridview control and a label control. The grid view is usedto show rows in the DB and when clicked to edit each row, a form view opens up in edit mode with that particular row info. So I have nothing in the item template.My first question is..is it mandatory to have smth in the itemtemplate of the form view.I have controls in edititemtemplate and insertitemtemplate.When a particular row is edited, I would like to show a status msg showing that the row has been updated.For this, I use the ItemUpdated event of the formview and try ...

Web resources about - Master page's "Load" event is later than content page's ? - asp.net.navigation-controls

Resources last updated: 12/20/2015 9:46:03 AM