Asp.Net Page Life Cycle

 
This is important article for developer that shows how to perform page execution and display contents on browser.

When browser send request to server then page instance created and process-Request will be invoked for processing the pages instance.

There are the following steps for page life cycle events.

1: Page Init :

– page have three steps:

(a) PreInIt

(b) InIt

(c) InItComplete

PreInIt:

This is entry point of page life cycle. On this event we can set master page controls values dynamically and set the theme.

InIt:

Init This event fires after each control has been initialized, each control’s UniqueID is set and any skin settings have been applied. You can use this event to change initialization values for controls.

InItComplete:

This event raised initialization of all controls has been completed. Till now view state is not loaded into memory. On this event we can make changes into view state for persist into round trip.

(2) Page Load:

Raised after the page loads view state for itself and all controls, and after it processes postback data that is included with the Request instance

(a)Loads ViewState : ViewState data are loaded to controls.

The page viewstate is managed by ASP.NET and is used to persist information over a page roundtrip to the server. Viewstate information is saved as a string of name/value pairs .

(b) Loads Postback data :

During this phase of the page creation, form data that was posted to the server is processed against each control that requires it.

sets control properties appropriately.

checks for PostBack to avoid unnecessary restore state and avoid unnecessary round trip.

(3)PostBack event Control:

On this stage the events which makes round trip to server are initialized. Like button click or drop selection change or so many.

(4) LoadComplete :

This event signals that all other controls on page loaded successfully.

(5) PreRender :

Allow final changes to the page and its control. this event takes place after all regular postback events have taken place. This event take place before saving view state so any changes required in controls properties can perform here. After this event change in control properties not accepted.

(6) Render:

Render events responsible for display the controls on browser. This event convert server side control into html control. We can verify this thing by right click on page and see view source code. Then you will all control on converted into HTML.

(7) UnLoad:

This event is used for cleanup code. After the page’s HTML is rendered, the objects are disposed of. it is safe to dispose of any remaining objects, including the Page object.

I hope after read this article things will be clear .

Author: Pavan

I am asp.net developer have good knowledge of Asp.net ver 05,08,10 and good hand in sql server.Proficient in Object Oriented Programming and javascript, jQuery. Achievements - Integrate Spotfire, appnexus API ASP.net with sql server. Hobbies - Blogging ,Games, Movies ,Teaching,Keeping myself update with new technologies

One thought on “Asp.Net Page Life Cycle”

Comments are closed.