In the ASP.Net page, when the page is called and render the data to the user browser, some events will be occurred, which are called as ASP.Net lifecycle events.
They are
- Initialization
- Load
- Render
- Unload
Initialization could happen in 3 stages.
PreInit, Init, and InitComplete
PreInit
IsPostBack, IsCallBack and IsCrossPostBack properties are set at this stage. This event allows us to set the master page and theme of the web page dynamically. This could be more useful when we are working with dynamic web pages.
protected void Page_PreInit(object sender, EventArgs e)
{
}
Init
This event is to set or initialize the control properties. Server controls get the initialization or load using View state on this event.
protected void Page_Init(object sender, EventArgs e)
{
}
InitComplete
Raised at the end of the page's initialization event. Only one action takes place between the Init and InitComplete events. Identification of view state changes is turned on. View state tracking enables controls to persist any values that are programmatically added to the ViewState collection. Until view state tracking is turned on, any values added to view state are lost across postbacks. Controls typically turn on view state tracking immediately after they raise their Init event.
protected void Page_InitComplete(object sender, EventArgs e)
{
}
The Load has three events.
PreLoad, Load, and Load complete.
PreLoad:
This event is occurs before the postback(ViewState) data is loaded into the controls. We can make control property changes in the stage.
protected override void OnPreLoad(EventArgs e )
{
}
Load:
This event is raised for the page first time and then repeatedly for all controls exist in the page.
protected void Page_Load(object sender, EventArgs e)
{
}
LoadComplete
This event raises after the control events are handled
protected void Page_LoadComplete (object sender, EventArgs e)
{
}
PreRender
This event occurs after the page object has created and all controls that are required in order to render the page.
protected override void OnPreRender(EventArgs e)
{
}




SQL Server
C#.Net
ASP.Net
ADO.Net
jQuery
No comments:
Post a Comment