Order of page requests
When a user requests a page built on the master page, the order of events is as follows:
Master page subcontrol initialization;
Content Page subcontrol initialization;
Master page initialization;
Content Page initialization;
Content Page page_load;
Page_load of the master page;
Master page sub-control loading;
Content Page sub-control loading;
Note:
Because the page_load of the content page is prior to the page_load of the master page, to access the server control in the master page, you must write code in the page_loadcomplete method of the Content Page.
Asp.net page event Loading Sequence
The page will be activated in the following order:
Page. preinit
Page. init
Page. initcomplite
Page. Preload
Page. Load
Page. loadcomplete
Page. prerender
Page. prerendercomplete
If the page inherits from another page, such as basepage: system. web. UI. page, some extensions are made in the basepage, such as permission check. When other pages inherit from the basepage, the order of activation of the events of the basepage and the final page is:
Ui. preinit
Page. preinit
Ui. init
Page. init
Ui. initcomplite
Page. initcomplite
Ui. Preload
Page. Preload
Ui. Load
Page. Load
Ui. loadcomplete
Page. loadcomplete
Ui. prerender
Page. prerender
Ui. prerendercomplete
Page. prerendercomplete
If masterpage is used, the events in masterpage and those in contentpage are activated in the following order:
Contentpage. preinit
Master. init
Contentpage. init
Contentpage. initcomplite
Contentpage. Preload
Contentpage. Load
Master. Load
Contentpage. loadcomplete
Contentpage. prerender
Master. prerender
Contentpage. prerendercomplete
Furthermore, if contentpage inherits the basepage, the execution sequence of each event is changed:
Ui. preinit
Contentpage. preinit
Master. init
Ui. init
Contentpage. init
Ui. initcomplite
Contentpage. initcomplite
Ui. Preload
Contentpage. Preload
Ui. Load
Contentpage. Load
Master. Load
Ui. loadcomplete
Contentpage. loadcomplete
Ui. prerender
Contentpage. prerender
Master. prerender
Ui. prerendercomplete
Contentpage. prerendercomplete
I did not find the Asp.net 1.1 I have learned now. It is estimated that it should be Asp.net 2.0,
But it does not matter, which makes me know the order in which they are loaded during inheritance.
That is, the inherited page is loaded first. If the inherited page has an inherited page, the inherited page is loaded first.
It is actually a very simple content. Write down the page event by the way (I don't know if 1.1 is the case)
Event processor name |
Occurrence time |
Page_init |
Load and initialize the Server Control in the view status of the web form. This is the first step in the web form lifecycle. |
Page_load |
Load the server control on the page object. The view status information can be used at this time, Therefore, you can use code to change the space settings or display text on the page. |
Page_prerender |
The application will present the Page Object |
Page_unload |
Page detached from memory |
Page_error |
An unhandled exception occurred. |
Page_aborttransaction |
Transaction Processing terminated |
Page_committransaction |
Transaction Processing accepted |
Page_databinding |
Bind the server space and data source on the page |
Page_disposed |
The page object is released from the memory. This is the last event in the lifecycle of the page object. |