general page life-cycle stage in ASP.NET

general page life-cycle stage in ASP.NET

page life-cycle:-

  • Page request:- the page request occurs before the page life cycle begins. when the page requested by a user, ASP.NET determines whether the page needs to be parsed and compiled or whether a cached version of the page can be sent in response without running the page.

 

  • Start:- in the start step, page properties such as a request and response are set. at this stage, the page also determines whether the request is postback or a new request and sets the Ispostback property. the page’s UIculture property is set.

 

  • Page initialization:-  each control’s uniqueID property is set and controls on the page are available. any themes are also applied. if the current request is a postback, the postback data has not yet been loaded and control property values have not been restored to the values from view state.

 

  • Load:- if the request is a postback, then control properties are loaded with information and recovered from view state and control state.

 

  • Validation:-  the validation method of all validator controls is called, which sets the Isvalid property of individual validator controls and of the page.

 

  • Postback event handling:- 
  • Rendering:- This is not an event; instead, at this stage of processing, the page object calls this method on each control. All ASP.NET Web server controls have a render method that writes out the control’s markup to send to the browser.
  • Unloading:- unload is called after the page has been fully rendered, sent to the client, and is ready to be discarded. at this point, page properties such as response and request are unloaded and any cleanup performed.
page life-cycle

page life-cycle

understanding page events sequence and its purpose:-

preint:- You can:

  • this is the first time the page is being processed, then Checking the IsPostBack property to identify it.
  • Create or re-create dynamic controls.
  • Set master page dynamically.
  • Set the Theme property dynamically.
  • Read or set profile property values.
  • If Request is postback:

 

  • int:-  it occurs after all controls have been initialized and any skin settings have been applied.

-> use this event to read or initialize control properties.

  • initcomplete:-  occures by the page object.
  • this event is use for processing tasks that require all initialization to be compelte.
  • preload:-

-> This event processes the postback data that is included in the request.

  • load:- 

-> the Page object calls the OnLoad method on the Page object itself, then later the OnLoad method of the controls is called.

-> Thus Load event of the individual controls occurs after the page.

  • control events:-  this event used to handle specific control events, such as a button control’s click event or textbox control’s text changed event.

 

  • load complete:- 

-> This event occurs after the event handling stage.

-> This event is used for loading all other controls on the page.

  • prerender:- 
    • In this the PreRender event of the page is called first and later for the child control.

    Usage:

    • this event is use to make final changes to the contents of the page or its controls.
  • PreRenderComplete:
    • This event occurs after each control’s PreRender property is completed.
  • SaveStateComplete:
    • This is raised after the control state and view state has been saved for the page and for all controls.
  • RenderComplete:
    • This method writes the control’s markup to send it to the browser.
  • Unload:
    • this event control is used for final cleanup work, such as closing open database connections, closing open files, etc.
Life Cycle Comparison

Life Cycle Comparison













Reply