Categorized | ASP.NET FAQ

ASP.net page Life cycle

Below Page life cycle  events executed in the sequence.

1.Page_Init 2.LoadViewState ( If the request  is a post back ) 3. Page_Load 4.Post Back events (  Ex :Button_Click ) 5.Page_PreRender 6.SaveViewState  7.Render 8.UnLoad

What happens when these events fired.

Page_Init : 1.In the intialization Phase all the controls  UniqueID property in that page will be set. 2.All Master pages and Themes and skins will be set. 3. Post back data is not available in this phase ( If the request is post back request ) 4. Page Controls Init event is Executed before Page_InIt

LoadViewState : 1. This event is fired only when the request is PostBack request. 2. All the control properties loaded with Controls ViewState values.

Page_Load: 1.All the control loaded fully with their properties. 2.Page_Load occurs first and then the Child controls Load will happen next. Ex: If you have Text Box named ” txtAge” on the Page Patient.aspx, first Page_Load will occur and txtAge_Load happens Next.

PostBack Events: 1. Post back events like Button_Click and TextBox1_TextChanged, Dropdown list “SelectedIndex_Changed” events will be fired in this stage.

Page_PreRender: 1.Sequence is Page_PreRender followed by ChildControls_PreRender 2.Inthis event Programmer can be able to change Response object.

SaveViewState: 1.ViewState for all the controls will be saved

Page_Render: 1. This method is responsible for generating html code for the page and also for all the controls. This can be done by Calling Render method for individual controls and for the page it-self.( We will see an example for this while working with Custom Controls )

Page_UnLoad: 1. Memory created for the Page class will be removed from the server ( IIS).

Note : For more info You can visit http://msdn.microsoft.com/en-us/library/ms178472(v=VS.90).aspx

EasyFreeAds Blog News Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google Yahoo Buzz StumbleUpon

9 Responses to “ASP.net page Life cycle”

  1. surya says:

    Good and simple explanation, can be elaborated

  2. subhashini says:

    Nice Explanation

  3. sreepriya says:

    Good explanation

  4. Lokeswar says:

    Nice explanation……….

  5. khaja says:

    this is really good for interview point of view.this is the first question to be asked in the interviews for asp.net programmers

  6. shibsankar says:

    sir i am not getting what is initial handShaking in asp.net?

  7. Lok says:

    This will be explained when we came into the Connection pooling technique in ado.net

  8. shibsankar says:

    sir this is shibsankar. i am not getting what is AutoEventWireUp in asp.net? please give explain with some example

  9. hari says:

    webmethod is overridable in webservice? if it is possible how?

Trackbacks/Pingbacks


Leave a Reply