Does master page get called first?
Asked Answered
P

4

11

I would assume this is true, but wanted to throw this question up. Is the master page executed first in ASP.NET, or does the page which is getting retrieved?

I am asking because I want some processing to be done in the master page, results of which are loaded into a static object and which can then be used by the called page (for instance user data)

Pulverulent answered 8/5, 2012 at 19:41 Comment(1)
Did you check this answer?Trapani
E
22

Sorry for just quoting, but i don't know what to add:

Individual ASP.NET server controls have their own life cycle that is similar to the page life cycle. For example, a control's Init and Load events occur during the corresponding page events.

Although both Init and Load recursively occur on each control, they happen in reverse order. The Init event (and also the Unload event) for each child control occur before the corresponding event is raised for its container (bottom-up). However the Load event for a container occurs before the Load events for its child controls (top-down). Master pages behave like child controls on a page: the master page Init event occurs before the page Init and Load events, and the master page Load event occurs after the page Init and Load events.

http://msdn.microsoft.com/en-us/library/ms178472.aspx

enter image description here

Eindhoven answered 8/5, 2012 at 19:46 Comment(1)
I think it's OK to quote the documentation while also providing a link. The quote brings reader to solution more quickly - plus, I believe you likely streamlined the doc, given the OP's question as context. I found the detail to my answer in the image you put up front in your answer. Makes for a useful post.Bawd
T
8

Execution Priority

  1. Content Page
  2. Master Page
  3. User Control
Trapani answered 8/5, 2012 at 19:51 Comment(0)
P
4

Most page events will get called before the corresponding ones on the master page are (in essence the master page is considered a part of the page it is linked to - it is a user control).

See ASP.Net 2.0 - Master Pages: Tips, Tricks, and Traps on OdeToCode for details.

Potentate answered 8/5, 2012 at 19:44 Comment(1)
Master page is actually a user control :)Munday
M
0

you could look at the .net documentation which states when and in what order events are called

see this, this and this

Mycology answered 8/5, 2012 at 19:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.