Page life cycle

Source: Internet
Author: User

Because, has been to asp.net in the life cycle of the problem of confusion, so specifically to learn the next life cycle.

Life cycle I think the main can be divided into several stages, according to the chronological order of occurrence

1. Initialize page frame

This process triggers the page. Init event, which runs when various events are triggered. Note, however, that, as with his name, this is the initialization of the page frame, so it is not possible to do UI behavior.

2, Application code initialization

This process corresponds to the event Page_Load, in which the asp.net determines that the page is back-loaded for the first time. However, even so Page_Load runs when various events are triggered. Therefore, you can use IsPostBack to write auxiliary operations.

3. Perform event handling

If this is the first load, the user-triggered events, such as the Click event, will not run. Is the direct execution of the Page_PreRender event. At this point, the main sequence of events for the whole process is Page_init-page_load-page_prerender

However, if the user triggers the event, and if the Click action occurs, the entire process becomes Page_init-page_load-click event-page_prerender

Of course there are other processes in addition to these three processes, and I have omitted some of the less important process of personal feeling in order to make the life cycle look simpler.

So what is the effect of these three processes on us?

First we know the execution order and the execution nature of the page_init-page_load-page_prerender, then we can initialize some data in this order. For example, for the class that Page_Init belongs to, we can initialize some of its fields with Page_Init, while the ASP.net control initialization can be placed in Page_Load, and finally the user-defined UI controls need to be in the Page_ PreRender in the middle of the. The purpose of this is to ensure that every time the control is executed, the basis for running it is complete.

These are some of my personal experience, I hope to be useful to everyone, the wrong place please haihan and correct me.

The life cycle of the asp.net.

1. beginrequest
2. AuthenticateRequest
3. Postauthenticaterequest
4. AuthorizeRequest
5. Postauthorizerequest
6. Resolverequestcache
7. Postresolverequestcache
8. Postmaprequesthandler
9. AcquireRequestState
Postacquirerequeststate
PreRequestHandlerExecute.
At this stage, the selected handler executes the current request. The most familiar handler is the
Page handler.
PostRequestHandlerExecute
ReleaseRequestState
Postreleaserequeststate
Updaterequestcache
Postupdaterequestcache
EndRequest

The 12th step is the following steps:

Page.onpreinit
Masterpagecontrol.oninit (for all control on the master page)
Control.oninit (for all contol on the page)
Masterpage.oninit
Page.oninit
Page.oninitcomplete
Page.onpreload
Page.onload
Masterpage.onload
Masterpagecontrol.onload (for all control on the master page)
Control.onload (for all contol on the page)
Page.onxxx (Control event)
Masterpage.onbubbleevent
Page.onbubbleevent
Page.onloadcomplete
Page.onprerender
Masterpage.onprerender
Masterpagecontrol.onprerender (for all control on the master page)
Control.onprerender (for all contol on the page)
Page.onprerendercomplete
Masterpagecontrol.savecontrolstate (for all control on the master page)
Control.savecontrolstate (for all contol on the page)
Page.saveviewstate
Page.savepagestatetopersistencemedium
Page.onsavestatecomplete
Masterpagecontrol.onunload (for all control on the master page)
Control.onunload (for all contol on the page)
Masterpage.onunload
Page.onunload

I was directly posted by someone else's summary, hehe

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.