Master page, the execution sequence of the user control, provided that there is A page A, reference master page B, both of which reference the user control,
User Control A is on page A, and user control B is on master page B. I will record their execution sequence.
Note:
First, execute the Load event of page.
Next, run the Load event of master page B.
Then run the Load event of user control B on master page B.
Finally, run the Load event of user control A on page.
This is what I found during debugging, and I hope to give it to the same ASP. NET developer help. the customer sends a POST request-> Create a Page derived class and call the constructor-> call the IHttpHandler of the Page class. processRequest method-> activate the Init event of the Page class-> call the CreateChildControls virtual method of the Page class-> restore the server-side control status from the POST variable and VIEWSTATE-> activate the Load event of the Page class -> activate the control event on the server-> activate the PreRender event of the Page class-> call the Render virtual method of the Page class-> call the RenderChildren virtual method of the Page class-> send an HTTP Response to the client -> activate the Unload event of the Page class-> discard the instance of the Page derived class.
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 a page is inherited from a 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