Event execution sequence of pages and user controls in ASP. NET

Source: Internet
Author: User

The order of events when the user control webusercontrol1 is directly placed on the webform1 page:

Webusercontrolpolicinit

Webform1_init

Page_load

Webusercontrolpolicload

Webform1_prerender

Webusercontrolpolicprerender

Webusercontrolpolicunload

Webform1_unload

In the oninit method of the webform1 page, use the code to load the event sequence when the user controls webusercontrol1:

Webform1_init: oninit

Webform1: loading controls

Webusercontrolpolicinit: oninit

Webform1: added to controls

Webform1: loadviewstate

Webusercontrol1: loadviewstate

Webusercontrol1: loadpostdata begin

Webusercontrol1: loadpostdataend

Webform1_pageload: onload after base's onload.

Webusercontrolpolicload: afterbase's onload

Webusercontrol1: raisepostdatachange

Webform1: onprerender

Webusercontrol1: onprerender

Webform1: savedviewstate

Webusercontrol1: saveviewstate

In the page_load method of the webform1 page, use the code to load the event sequence when the user controls webusercontrol1:

Webform1_init: oninit

Webform1: loadviewstate

Webform1_pageload: onload afterbase's onload.

Webform1: loading controls

Webusercontrolpolicinit: oninit

Webusercontrol1: loadviewstate

Webform1: added to controls

Webusercontrolpolicload: After base's onload

Webusercontrol1: loadpostdata begin

Webusercontrol1: loadpostdata end

Webusercontrol1: raisepostdatachange

Webform1: onprerender

Webusercontrol1: onprerender

Webform1: savedviewstate

Webusercontrol1: saveviewstate

The order of the events in the webform1 page when the Code load user control webusercontrol1 is used in the button#click event:

Webform1_init

Page_load

Button#click

Webusercontrolpolicinit

Webusercontrolpolicload

Webform1_prerender

Webusercontrolpolicprerender

Webusercontrolpolicunload

Webform1_unload

In the page_load event of the webform1 page, use the code load user control webusercontrol1. In the page_load event, use the code load user control webusercontrol2 to display the event sequence:

Webform1_init

Page_load

Webusercontrolpolicinit

Webusercontrolpolicload

Webusercontrol2_init

Webusercontrol2_load

Webform1_prerender

Webusercontrolpolicprerender

Webusercontrol2_prerender

Webusercontrol2_unload

Webusercontrolpolicunload

Webform1_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.