Jan 24

Page Life Cycle

Page Life Cycle Stage

Page request : The Page request occurs before page life cycle begin. Page request means, Its decides whether page parse and compile, or whether cache version to be sent in  response without running the page.

Start : In this stage, page property like request and response are set. The page are also determines whether the request is postback or a new request and set the IsPostBack property

Page initialization :  In this stage, control on the page are rendered and each control’s uniqueID property set and the themes are applied. If the current request is a postback, the  postback data has not yet been loaded and the control property values have not been restored to the value from view state.

Load : In postback. Control properties are loaded with information recovered from view state and control state.

Validation : Validation is validate of all validator control and set Isvalid property of individual validator controls and of the page.

Postback event handling : if the request is postback then related event handler is invoke.

Rendering : Before rendering view state is saved for page and all controls. During rendering, the page call render method for each control.

Unload : The rendered page is sent to the client and page properties, such as Response and Request, are unloaded and all cleanup done.

Page Life Cycle Event

PreInit : Page Life Cycle have a Pre-initialization phase which is called “PreInit”. In this event, programmatically access the master page and theme is allowed. Event use for following.

  • IsPostback property to determine whether this is the first time the page is being processed.
  • Create or re-create dynamic control
  • Set a master page dynamically
  • Set the theme property dynamically
  • Read and set profile property value

Init :  This event fire after (PreInit) each controls has been initialized. Each control’s UniqueID is set. This event can be handle by overloading the OnInit method or create Page_Init handler. Use this event to read and initialize control property.

InitComplete :  Use This event for processing task that require all initialization be complete.

PreLoad :  Raised after the page loads view state for itself and all control, and then processes any postback data included with the request instance. This event can be handle by  overloading the OnPreLoad Method.

Load : The Load Event raised for the page first then recursively for all child control.  If page is postback then restore its previous state. Page first check for postback and then set control properties appropriately. OnLoad event is use to set properties in control and establish the database connection.

Control Events: This event is use for handle specific control event. Such as “button control”, “Click Event”, “Textbox Control’s” and “textchanged event”

LoadComplete: This event fire after the load event.

PreRender: This event fire just before the render of all control. After this event we can not change any property and view state value.

SaveStateComplete: before this event view state has been saved for page and for all control. Any changes to the page or controls at this point will be ignored. The HTML page is  generated.

Render : This is not event. This is method of the page object and its control. This method is call on each page’s  to get its output.

Unload:  This event occurs for each control and then for the page. This method use for final cleanup for specific control , such as closing control-specific database connection.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>