Event Ordering:
When you work with master pages and content pages, both can use the same events (such as Page_Load). Be sure you know which events come before others for this combination to work and making your own life easier. You are bringing two classes together to create a single page class, and a specific order is required. When an end user requests a content page in the browser, the event ordering is the following:
When you work with master pages and content pages, both can use the same events (such as Page_Load). Be sure you know which events come before others for this combination to work and making your own life easier. You are bringing two classes together to create a single page class, and a specific order is required. When an end user requests a content page in the browser, the event ordering is the following:
❑ Master page child controls initialization: All server controls contained within the master page are first initialized.
❑ Content page child controls initialization: All server controls contained in the content page are initialized.
❑ Master page initialization: The master page itself is initialized.
❑ Content page initialization: The content page is initialized.
❑ Content page load: The content page is loaded (this is the Page_Load event followed by the Page_LoadComplete event).
❑ Master page load: The master page is loaded (this is also the Page_Load event followed by the Page_LoadComplete event).
❑ Master page child controls load: The server controls on the master page are loaded onto the page.
❑ Content page child controls load: The server controls on the content page are loaded onto the page.
Pay attention to this event ordering when building your applications. If you want to use server control values that are contained on the master page within a specific content page, for example, you can’t retrieve the values of these server controls from within the content page’s Page_Load event. This is because this event is triggered before the master page’s Page_Load event. This problem prompted the creation of the new Page_LoadComplete event. The content page’s Page_LoadComplete event follows the master page’s Page_Load event. You can, therefore, use this ordering to get at values from the master page even though it isn’t populated when the content page’s Page_Load event is triggered.
Introduction of Master pages facilitated Visual Inheritance and having a clear understanding of the order of events fired when the Master page and Content pages are in action will help to utilize this feature to its maximum. Enjoy Programing...!!
Decent and clear cut explanation...
ReplyDelete