Wednesday, September 22, 2010

Asp.Net Page LifeCycle in 3 stages

Its hard to remember all the stages of an Asp.Net page’s life-cycle. So being able to group them into 3 stages is a useful way for looking at them:

  1. Initialisation
  2. Event Handler Execution
  3. Rendering

Initialization

  1. PreInit (Controls are available. Ids are set)
  2. Init
  3. InitComplete

Event Handler Execution

  1. Preload
  2. Load (During a post-back, control properties are available here and loaded from view state)
  3. Controls events (If a post-back call, events are fired and validation is performed by calling the Validate methods on each validator control – setting the IsValid property)
  4. Load Complete

Rendering

  1. PreRender (databind method is called here)
  2. SaveState
  3. Render
  4. Unload

More information: MSDN: ASP.Net Page Life Cycle

No comments: