Thursday, June 14, 2007

Event Life Cycle in Page Processing

When processes a web page, its event life cycle follows certain stages.

Importance of understanding Page Processing and different event occurs during it, will provide you better understanding of writing a code in proper event.

Imagine you have a page with a submit combo-box whose auto-postback property is true. Now whenever value of combo-box is changed a selectedIndex event is fired, but before that a series of other event fires.

For above scenario Event Life Cycle executes in following manner
1> Page.Init Event
2> Page.Load Event
3> Combo-box SelectedIndex Change Event
4> Page.PreRender Event
5> Page.Unload Event

This event life cycle will be proves to be blessing, when we are creating a dynamic control. For example in above case, lets assumed that whenever combo-box value changed we want to initialize certain control whose value based on combo-box selection. So how will you do it??? Answer is you can create dynamic controls in Page.Load Event and Initialize its value based on combo-box selection in Page.PreRender Event.

Functionality of Events

Page Initialization in

Initialization of Page is been done, by creating a Instance of page. It is the best place to store initialization code related to page.
eg: uses Init event to attach event handler for other events.

Page Load Initialization in

Initialization of controls of page is been done. It is best place to create dynamic controls, or initialize the controls.
eg: Creation of Dynamic Control

Page PreRender Event in

This evnet occurs just before page is about to display. It is the best place to write code which requires to render based on value in controls.
eg: Initialization of dependent controls.

No comments:

Most Recent Post

Subscribe Blog via Email

Enter your email address:

Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.
Page copy protected against web site content infringement by Copyscape