Friday, November 19, 2010

ASP.NET Page Life Cycle Overview

It is important to understand how ASP.NET page life cycle works, as it provides insight about the series of processing steps it goes through and then you can write code at the appropriate life-cycle stage. Specially when you are developing custom controls, you need to be familiar with the page life cycle in order to correctly initialize controls, populate control properties with view-state data and run behavior code.

I am not going to explain all the stages and events of the page life cycle, as it is well documented on MSDN and other blogs. But I found a really good image which provides you an overview of the page life cycle. The following image shows some of the most important methods of the Page class that you can override in order to add code that executes at specific points in the page life cycle. The image also shows how these methods relate to page events and to control events. The sequence of methods and events in the illustration is from top to bottom, and within each row from left to right.

This above image is relevant to .NET framework 4.0. I am going to print this out and stick it somewhere near my desk. BTW, an easy way of remember the important page life-cycle stages is SILVER.

S – Start
I – Initialize
L – Load
V – Validate
E – Event Handling
R – Render

No comments:

Post a Comment