Overview Of The Asp Net Page Life Cycle
When running an ASP.NET webpage the page goes through a series of steps as it is being processed. This page life cycle includes: instantiating controls, restoring and maintaining state, running event handler code, and rendering. Having a good understanding of the page life cycle is important so that you know when in the process you should populate properties, initialize controls, run control behavior code, etc.
The stages of the page life cycle are:
- Page Request
- Start
- Initialization
- Load
- Postback event handling
- Rendering
- Unload
Within each of these stages there are many events that are raised, which allow you to run your code. A few fairly frequently used events that you would probably use are:
- PreInit
- Init
- InitComplete
- PreLoad
- Load
- Control Events
- LoadComplete
- PreRender
- PreRenderComplete
- SaveStateComplete
- Render
- Unload
In addition, you should also think about the life cycle of individual server controls themselves. These life cycles are similar to the page life cycle but operate independently of it. This is important to think about in many scenarios, such as data-bound controls that require use of data binding events, or login control events, or etc.
For more in-depth information on the ASP.NET Page Life Cycle check some of the following external resources: