0% found this document useful (0 votes)
6 views

ASP.net

NOne

Uploaded by

ali.fatmi
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

ASP.net

NOne

Uploaded by

ali.fatmi
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

ASP.

NET
ASP.NET Page Lifecycle
• In ASP.NET, a web page has execution lifecycle that includes various
phases. These phases include initialization, instantiation, restoring
and maintaining state etc. it is required to understand the page
lifecycle so that we can put custom code at any stage to perform our
business logic.
Page Lifecycle stages
1. Page request:
This stage occurs before the lifecycle begins. When a page is requested
by the user, ASP.NET parses and compiles that page.
2. Start:
In this stage, page properties such as Request and response are set. It
also determines the Request type.
3. Initialization:
In this stage, each control's UniqueID property is set. Master page is
applied to the page.
Page Lifecycle stages
4. Load:
During this phase, if page request is postback, control properties are loaded
with information.
5. Postback event handling:
In this stage, event handler is called if page request is postback. After that, the
Validate method of all validator controls is called.
6. Rendering:
Before rendering, view state is saved for the page and all controls. During the
rendering stage, the page calls the Render method for each control, providing
a text writer that writes its output to the OutputStream object of the page's
Response property.
Page Lifecycle stages
6. Unload
At this stage the requested page has been fully rendered and is ready to
terminate.at this stage all properties are unloaded and cleanup is
performed.
ASP.NET Life Cycle Events
1. PreInit
This event is raised after the start stage is complete and before the
initialization stage.
2. Init
This event occurs after all controls have been initialized.
We can use this event to read or initialize control properties.
3. InitComplete
This event occurs at the end of the page's initialization stage.
We can use this event to make changes to view state that we want to make
sure are persisted after the next postback.
ASP.NET Life Cycle Events
4. PreLoad
This event is occurs before the post back data is loaded in the controls.
5. Load
This event is raised for the page first time and then recursively for all
child controls.
6. Control events
This event is used to handle specific control events such as Button
control' Click event.
ASP.NET Life Cycle Events
7. LoadComplete
This event occurs at the end of the event-handling stage.
We can use this event for tasks that require all other controls on the page
be loaded.
8. PreRender
This event occurs after the page object has created all controls that are
required in order to render the page.
9. PreRenderComplete
This event occurs after each data bound control whose DataSourceID
property is set calls its DataBind method.
ASP.NET Life Cycle Events
10. SaveStateComplete
It is raised after view state and control state have been saved for the
page and for all controls.
11. Render
This is not an event; instead, at this stage of processing, the Page object
calls this method on each control.
12. Unload
This event raised for each control and then for the page.

You might also like