Tag Archives: phasse

ASP.NET Page Life Cycle

  • Page request A request to an ASPX page starts the life cycle of that page. When the web server is able and allowed to return a cached copy of the page, the entire life cycle is not executed. In all other situations, the page enters the start phase.
  • Start In this phase, the page gets access to properties like Request and Response that are used to interact with the page’s environment. In addition,during this phase the PreInit event is raised to signal that the page is about to go into the initialization phase.
  • Page initialization During this phase, the controls you have set up in your page or added programmatically become available. Additionally, the Page class fires three events: Init, InitComplete, and PreLoad. Also during this phase, the control properties are loaded from View State and Control State again during a postback. So, for example, when you change the selected item in a DropDownList and then cause a postback, this is the moment where the correct item gets preselected in the drop-down list again, which you can then work with in your server-side code.
  • Load During this phase the page raises the Load event.
  • Validation In the validation phase, the Validation controls used to validate user input are processed.
  • Postback event handling During this phase, the controls in your page may raise their own events. For example, the DropDownList may raise a SelectedIndexChanged event when the user has chosen a different option in the list. Similarly, a TextBox may raise the TextChanged event when the user has changed the text before she posted back to the server. When all event processing is done, the page raises the LoadComplete event. During this phase the PreRender event is raised to signal that the page is about to render to the browser. Shortly after that, SaveStateComplete is raised to indicate that the page is done storing all the relevant data for the controls in View State.
  • Rendering Rendering is the phase where the controls (and the page itself) output their HTML to the browser.
  • Unload The unload phase is really a clean-up phase. This is the moment where the page and controls can release resources like database connections.During this phase, the Unload event is raised so you can handle any cleanup you may need to do.