Tuesday, May 25, 2010

ASP.Net page events



1. PreInit

We can check IsPostBack
Values are not present\saved in viewstate

This is used for settings that are global, like dynamically setting the master page, theme, date time etc
Dynamically controls can be added

2. Init

All controls are rendered
Use this to Read or Write control properties


3. InitComplete
All initialization done

Page loading

4. PreLoad
Us this for processing on page\control before the loading of controls
Viewstate gets initialized after this event
Postback data is been processed


5. Load
Recursively, all OnLoad events on the child controls are fired first
Specific any control event for an event gets fired, like TextChange for a TextBox

6. LoadComplete
All controls loaded
Viewstate put in place
Validation controls is loaded and executed

Validations can be checked here

7. PreRender
All controls are in memory,now its time to generate the HTML for these controls
for client side rendering
To make any final changes of the content and controls of the page


8. SaveStateComplete
Before this event, viewstate is saved
Any change done made on state of page, wont be rendered on browser

This event handler used to make sure viewstate is completed and use viewstate items

9. Render


The image attached with this post is used from MSDN.
The intention is to have some pictorial representation and the copyright belongs to MSDN or original author.