Order of page events in Asp.net

Source: Internet
Author: User
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.