- The page first retrieves the posted data from the QueryString or Form collection of the Request Object.
- The page then checks whether the posted Data collection (the NameValueCollection Form or QueryString) contains an item with the key __CALLBACKID. If it does, it sets its IsCallback Boolean property to true to signal that the page has been posted back to the server through theASP.NET client callback mechanism.
- PreInit: The page takes the following actions in the PreInit phase of its life cycle:
A. Calls its OnPreInit method to raise the PreInit event.
B. Initializes the theme by using the contents of the App_Themes directory to dynamicallyimplement a class of type PageTheme, compiles the class, creates an instance of thecompiled class, and assigns the instance to its PageTheme property.
C. Applies the master page. - Init: The page takes the following actions in the Init phase of its life cycle:
A. Recursively initializes the controls in its Controls collection. This initializationincludes setting the properties of these controls such as Page, ID, NamingContainer,and so on.
B. Recursively applies these controls’ skins.
C. Calls its own OnInit method to raise its own Init event and then recursively calls thechild control’s OnInit methods to raise their Init events.
D. Calls its own TrackViewState to start its own view state tracking and then recursivelycalls the child controls’ TrackViewState methods to start their view state tracking. - InitComplete: The page calls its OnInitComplete method to raise the InitComplete event.This event signals the end of the initialization phase. By this time all controls in the Controlscollection of the page are initialized.
- Load Control State (postback only): The page recursively calls the LoadControlState method of those controls in its Controls collection that have called the RegisterRequiresControlState method of the page class to express interest in using their control states.
- Load View State (postback only): The page first calls its own LoadViewState method and then recursively calls the LoadViewState method of the controls in its Controls collection to allowthem to load their saved view states.
- Load Post Data (postback only - first try): The page calls the LoadPostData method of the controls that implement the IPostBackDataHandler interface and passes the posted data into it.The LoadPostData method of each control must access the posted data and update the respective property of the control accordingly. For example, the LoadPostData method of the TextBoxcontrol assigns the new value of the text box to the Text property of the TextBox control.
- PreLoad: The page calls its OnPreLoad method to raise the PreLoad event. This event signalsthe beginning of the load phase of the page life cycle.
- Load: The page first calls its own OnLoad method to raise its own Load event and then recursively calls the OnLoad methods of the controls in its Controls collection to raise their Load events. Page developers may register callbacks for the Load event, where they may programmaticallyadd child controls to the Controls collection of the page.
- Load Post Data (postback only second try): The page calls the LoadPostData method of those controls that were programmatically added to its Controls collection in the Load phase if theyimplement the IPostBackDataHandler interface.
- Raise Post Data Changed Event (postback only): The page calls the RaisePostData ChangedEvent method of those controls whose LoadPostData method returned true. The RaisePostDataChangedEvent method raises post data changed event. For example, the TextBox control raises this event when the new value of the text box is different from the old value.
- Raise Postback Event (postback only): The page calls the RaisePostBackEvent method of the control whose associated HTML element submitted the form. For example, the Button control’s associated HTML element posts the page back to the server. The RaisePostBackEvent methodof a control must map the postback event to one or more server-side events. For example, the RaisePostBackEvent method of the Button control maps the postback event to the Command and Click server-side events.
- Load Complete: The page calls its OnLoadComplete method to raise the LoadComplete event to signal the completion of all loading activities including loading post data and raising postdata changed event to allow interested controls to update themselves accordingly.
- Raise Callback Event (postback and callback only): The page calls the RaiseCallbackEvent method of the control that uses the ASP.NET client callback mechanism to allow a client-side method (such as a JavaScript function) to call a server-side method without having to post theentire page back to the server. The RaiseCallbackEvent method must call the respective server-side methods. If the page is posted back through the client callback mechanism, the pagewill not go through the rest of its life cycle phases.
- PreRender: The page takes the following actions in this phase of its life cycle:
A. Calls its EnsureChildControls method to ensure its child controls are created before the page enters its rendering phase.
B. Calls its own OnPreRender method to raise its own PreRender event.
C. Recursively calls the OnPreRender methods of the controls in its Controls collection to raise their PreRender events. - PreRender Complete: The page calls its OnPreRenderComplete method to raise thePreRenderComplete event to signal the completion of all prerendering activities.
- Save Control State: The page recursively calls the SaveControlState method of those controls in its Controls collection that have called the RegisterRequiresControlState method ofthe page class to express interest in saving their control states.
- Save View State: The page first calls its own SaveViewState method and then calls the SaveViewState method of the controls in its Controls collection to allow them to save their view states.
- Save State Complete: The page calls its OnSaveStateComplete method to raise theSaveStateComplete event to signal the completion of all save state activities.
- Rendering: The page takes the following actions in this phase of its life cycle:
A. Creates an instance of the HtmlTextWriter class that encapsulates the output stream of the response.
B. Calls its RenderControl method and passes the HtmlTextWriter instance into it.The RenderControl method recursively calls the RenderControl methods of the child controls to allow each child control to render its HTML markup text. The HTML markup texts ofchild controls form the final HTML markup text that is sent to the client browser.
Wednesday, August 20, 2008
ASP.Net 2.0 Page Life Cycle Events
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment