. NET page event execution sequence

Source: Internet
Author: User

The customer sends a POST request-> Create a page derived class and call the constructor-> call ihttphandler. processrequest of the page class Method -> Activate the init event of the page class-> call the createchildcontrols virtual method of the page class-> restore the control status on the server 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 Customer Terminal-> 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

ASP. NET 2.0 page event execution sequence masterpage. masterusercontrol_ontop.ascxpage.aspxusercontrol_inpage.ascxusercontrol_onbuttom.ascx

Masterpage Usercontrolontop Page Usercontrolinpage Usercontrolonbuttom
Init
Init
Init
Init
Init
Load
Load
Load
Levels
Load
Controlevents Controlevents Controlevents Controlevents Controlevents
Prerender
Prerender
Prerender
Prerender
Prerender
Unload
Unload
Unload
Unload
Unload

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.