When asp.net 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 Asp.net
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: VS.net uses Init event to attach event handler for other events.
Page Load Initialization in Asp.net
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 Asp.net
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.