I have a Master page and a webpage that uses the Master page.
In both I have a Page_Load
event handler.
In which order are the Page_Load
handlers called? Content first then Master or Master first then content?
The master page defines placeholders for the content, which can be overridden by content pages. The output result is a combination of the master page and the content page. The content pages contain the content you want to display.
The master page establishes a layout and includes one or more ContentPlaceHolder controls for replaceable text and controls. The content page includes only the text and controls that are merged at run time with the master page's ContentPlaceHolder controls.
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.
Master page allows you to create a consistent look and behavior for all the pages in your web applications. Master Page Design is common for all the pages. Master page actually consists of two pieces, the master page itself and one or more content pages. A master page is an ASP.NET file with the extension .
The content page load event will fire before the master page load event.
See here for full order (MSDN: Events in ASP.NET Master and Content Pages)
Copying incase link goes dead:
The following is the sequence in which events occur when a master page is merged with a content page:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With