SlideShare a Scribd company logo
1 of 22
SIRYKT
Sharing Knowledge is Learning
ASP.NET Tutorial
Page Life Cycle
Page request
• The page request occurs before the
page life cycle begins. When the
page is requested by a user,
ASP.NET determines whether the
page needs to be parsed and
compiled (therefore beginning the
life of a page), or whether a cached
version of the page can be sent in
response without running the page.
Life-Cycle Events
Page request
Start
Initialization
Load
Postback event handling
Rendering
Unload
Start
• In the start stage, page properties
such as Request and Response are
set. At this stage, the page also
determines whether the request is
a postback or a new request and
sets the IsPostBack property. The
page also sets the UICulture
property.
Life-Cycle Events
Page request
Start
Initialization
Load
Postback event handling
Rendering
Unload
Initialization
• During page initialization, controls
on the page are available and each
control's UniqueID property is set.
• A master page and themes are also
applied to the page if applicable.
• If the current request is a postback,
the postback data has not yet been
loaded and control property values
have not been restored to the
values from view state.
Life-Cycle Events
Page request
Start
Initialization
Load
Postback event handling
Rendering
Unload
Load
• During load, if the current request
is a postback, control properties are
loaded with information recovered
from view state and control state.
Life-Cycle Events
Page request
Start
Initialization
Load
Postback event handling
Rendering
Unload
Postback event handling
• If the request is a postback, control
event handlers are called. After
that, the Validate method of all
validator controls is called, which
sets the IsValid property of
individual validator controls and of
the page. (There is an exception to
this sequence: the handler for the
event that caused validation is
called after validation.)
Life-Cycle Events
Page request
Start
Initialization
Load
Postback event handling
Rendering
Unload
Rendering
• Before rendering, view state is
saved for the page and all controls.
During the rendering stage, the
page calls the Rendermethod for
each control, providing a text writer
that writes its output to the
OutputStream object of the page's
Responseproperty.
Life-Cycle Events
Page request
Start
Initialization
Load
Postback event handling
Rendering
Unload
Unload
• The Unload event is raised after the
page has been fully rendered, sent
to the client, and is ready to be
discarded.
• At this point, page properties such
as Response and Request are
unloaded and cleanup is
performed.
Life-Cycle Events
Page request
Start
Initialization
Load
Postback event handling
Rendering
Unload
PreInit
• Raised after the start stage is complete and before the
initialization stage begins.
• Use this event for the following:
• Check the IsPostBack property to determine whether this
is the first time the page is being processed.
The IsCallbackand IsCrossPagePostBack properties have
also been set at this time.
• Create or re-create dynamic controls.
• Set a master page dynamically.
• Set the Theme property dynamically.
• Read or set profile property values.
• To see the events execution order, create a new asp.net
web project, and copy the following code.
protected void Page_PreInit(object sender, EventArgs e)
{ Response.Write("Page_PreInit" + "<br/>"); }
Life-Cycle Events
PreInit
Init
InitComplete
PreLoad
Load
Control events
LoadComplete
PreRender
PreRenderComplete
SaveStateComplete
Render
Unload
Init
• Raised after all controls have been
initialized and any skin settings have been
applied. The Init event of individual
controls occurs before the Init event of
the page.
• Use this event to read or initialize control
properties.
• To see the events execution order, create
a new asp.net web project, and copy the
following code.
• Protected
void Page_Init(object sender, EventArgs e)
{ Response.Write("Page_Init" + "<br/>"); }
Life-Cycle Events
PreInit
Init
InitComplete
PreLoad
Load
Control events
LoadComplete
PreRender
PreRenderComplete
SaveStateComplete
Render
Unload
InitComplete
• Raised at the end of the page's initialization stage. Only
one operation takes place between the Init and
InitComplete events: tracking 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.
• Use this event to make changes to view state that you
want to make sure are persisted after the next postback.
• To see the events execution order, create a new asp.net
web project, and copy the following code.
• protected
void Page_InitComplete(object sender, EventArgs e)
{ Response.Write("Page_InitComplete" + "<br/>"); }
Life-Cycle Events
PreInit
Init
InitComplete
PreLoad
Load
Control events
LoadComplete
PreRender
PreRenderComplete
SaveStateComplete
Render
Unload
Preload
• Raised after the page loads view state
for itself and all controls, and after it
processes postback data that is
included with theRequest instance.
• To see the events execution order,
create a new asp.net web project, and
copy the following code.
• protected
void Page_PreLoad(object sender, Even
tArgs e)
{Response.Write("Page_PreLoad" + "<b
r/>"); }
Life-Cycle Events
PreInit
Init
InitComplete
PreLoad
Load
Control events
LoadComplete
PreRender
PreRenderComplete
SaveStateComplete
Render
Unload
Load
• The Page object calls the OnLoad method on the
Page object, and then recursively does the same
for each child control until the page and all
controls are loaded.
• The Load event of individual controls occurs after
the Load event of the page.
• Use the OnLoad event method to set properties in
controls and to establish database connections.
• To see the events execution order, create a new
asp.net web project, and copy the following code.
• protected
void Page_LoadComplete(object sender, EventArgs
e)
{
Response.Write("Page_LoadComplete" + "<br/>");
}
Life-Cycle Events
PreInit
Init
InitComplete
PreLoad
Load
Control events
LoadComplete
PreRender
PreRenderComplete
SaveStateComplete
Render
Unload
Control events
• Use these events to handle specific
control events, such as a Button
control's Click event or a TextBox
control's TextChangedevent.
Life-Cycle Events
PreInit
Init
InitComplete
PreLoad
Load
Control events
LoadComplete
PreRender
PreRenderComplete
SaveStateComplete
Render
Unload
PreRender
• Raised after the Page object has created all controls that
are required in order to render the page, including child
controls of composite controls. (To do this, the Page
object calls EnsureChildControls for each control and for
the page.)
• The Page object raises the PreRender event on the Page
object, and then recursively does the same for each child
control. ThePreRender event of individual controls occurs
after the PreRender event of the page.
• Use the event to make final changes to the contents of the
page or its controls before the rendering stage begins.
• To see the events execution order, create a new asp.net
web project, and copy the following code.
• protected
void Page_PreRender(object sender, EventArgs e)
{ Response.Write("Page_PreRender" + "<br/>"); }
Life-Cycle Events
PreInit
Init
InitComplete
PreLoad
Load
Control events
LoadComplete
PreRender
PreRenderComplete
SaveStateComplete
Render
Unload
PreRenderComplete
• Raised after each data bound control
whose DataSourceID property is set
calls its DataBind method.
• To see the events execution order,
create a new asp.net web project, and
copy the following code.
• protected
void Page_PreRenderComplete(object
sender, EventArgs e)
{
Response.Write("Page_PreRenderCom
plete" + "<br/>"); }
Life-Cycle Events
PreInit
Init
InitComplete
PreLoad
Load
Control events
LoadComplete
PreRender
PreRenderComplete
SaveStateComplete
Render
Unload
SaveStateComplete
• Raised after view state and control state have
been saved for the page and for all controls.
• Any changes to the page or controls at this
point affect rendering, but the changes will not
be retrieved on the next postback.
• To see the events execution order, create a
new asp.net web project, and copy the
following code.
• protected
void Page_Unload(object sender, EventArgs e)
{
//Response.Write("Page_Unload" + "<br/>");
}
Life-Cycle Events
PreInit
Init
InitComplete
PreLoad
Load
Control events
LoadComplete
PreRender
PreRenderComplete
SaveStateComplete
Render
Unload
Render
• This is not an event; instead, at this stage of processing,
the Page object calls this method on each control. All
ASP.NET Web server controls have a Render method that
writes out the control's markup to send to the browser.
• If you create a custom control, you typically override this
method to output the control's markup. However, if your
custom control incorporates only standard ASP.NET Web
server controls and no custom markup, you do not need
to override theRender method. For more information, see
Developing Custom ASP.NET Server Controls.
• A user control (an .ascx file) automatically incorporates
rendering, so you do not need to explicitly render the
control in code.
• To see the events execution order, create a new asp.net
web project, and copy the following code.
Life-Cycle Events
PreInit
Init
InitComplete
PreLoad
Load
Control events
LoadComplete
PreRender
PreRenderComplete
SaveStateComplete
Render
Unload
Unload
• Raised for each control and then for the page.
• In controls, use this event to do final cleanup
for specific controls, such as closing control-
specific database connections.
• For the page itself, use this event to do final
cleanup work, such as closing open files and
database connections, or finishing up logging
or other request-specific tasks.
• To see the events execution order, create a
new asp.net web project, and copy the
following code.
Life-Cycle Events
PreInit
Init
InitComplete
PreLoad
Load
Control events
LoadComplete
PreRender
PreRenderComplete
SaveStateComplete
Render
Unload
Login Control Event
LoggingIn
• Raised during a postback, after the page's LoadComplete event has occurred. This event marks the
beginning of the login process.
• Use this event for tasks that must occur prior to beginning the authentication process.
Authenticate
• Raised after the LoggingIn event.
• Use this event to override or enhance the default authentication behavior of a Login control.
LoggingIn
• Raised after the user name and password have been authenticated.
• Use this event to redirect to another page or to dynamically set the text in the control. This event
does not occur if there is an error or if authentication fails.
LoginError
• Raised if authentication was not successful.
• Use this event to set text in the control that explains the problem or to direct the user to a different
page.
Leave feedback & question in the comments
for our channel updates
Hit on like button below
For more visit our website
www.sirykt.blogspot.com

More Related Content

What's hot

ASP.Net Presentation Part1
ASP.Net Presentation Part1ASP.Net Presentation Part1
ASP.Net Presentation Part1
Neeraj Mathur
 
Ajax control tool kit
Ajax control tool kitAjax control tool kit
Ajax control tool kit
Vidhi Patel
 

What's hot (18)

Parallelminds.asp.net with sp
Parallelminds.asp.net with spParallelminds.asp.net with sp
Parallelminds.asp.net with sp
 
Asp.net control
Asp.net controlAsp.net control
Asp.net control
 
Asp.net life cycle
Asp.net life cycleAsp.net life cycle
Asp.net life cycle
 
Asp dot net lifecycle in details
Asp dot net lifecycle in detailsAsp dot net lifecycle in details
Asp dot net lifecycle in details
 
Page life cycle
Page life cyclePage life cycle
Page life cycle
 
Building Modern Web Applications using React and Redux
 Building Modern Web Applications using React and Redux Building Modern Web Applications using React and Redux
Building Modern Web Applications using React and Redux
 
Controls
ControlsControls
Controls
 
ASP.Net Presentation Part1
ASP.Net Presentation Part1ASP.Net Presentation Part1
ASP.Net Presentation Part1
 
Grails Connecting to MySQL
Grails Connecting to MySQLGrails Connecting to MySQL
Grails Connecting to MySQL
 
Rack
RackRack
Rack
 
Ajax control tool kit
Ajax control tool kitAjax control tool kit
Ajax control tool kit
 
Asp.net tips
Asp.net tipsAsp.net tips
Asp.net tips
 
2310 b 05
2310 b 052310 b 05
2310 b 05
 
Life cycle of web page
Life cycle of web pageLife cycle of web page
Life cycle of web page
 
Ajax control asp.net
Ajax control asp.netAjax control asp.net
Ajax control asp.net
 
Salesforce Lightning Tips & Tricks
Salesforce Lightning Tips & Tricks Salesforce Lightning Tips & Tricks
Salesforce Lightning Tips & Tricks
 
Jax Ws2.0
Jax Ws2.0Jax Ws2.0
Jax Ws2.0
 
METEOR 101
METEOR 101METEOR 101
METEOR 101
 

Similar to Page life cycle IN ASP.NET

Aspnet life cycle events
Aspnet life cycle eventsAspnet life cycle events
Aspnet life cycle events
Trushant parkar
 
Aspnetpagelifecycle 101129103702-phpapp02
Aspnetpagelifecycle 101129103702-phpapp02Aspnetpagelifecycle 101129103702-phpapp02
Aspnetpagelifecycle 101129103702-phpapp02
santoshkjogalekar
 
ASP.NET Session 6
ASP.NET Session 6ASP.NET Session 6
ASP.NET Session 6
Sisir Ghosh
 
M S Ajax Client Life Cycle Events
M S  Ajax  Client  Life  Cycle  EventsM S  Ajax  Client  Life  Cycle  Events
M S Ajax Client Life Cycle Events
51 lecture
 
State management 1
State management 1State management 1
State management 1
singhadarsh
 

Similar to Page life cycle IN ASP.NET (20)

Aspnet life cycle events
Aspnet life cycle eventsAspnet life cycle events
Aspnet life cycle events
 
Aspnetpagelifecycle 101129103702-phpapp02
Aspnetpagelifecycle 101129103702-phpapp02Aspnetpagelifecycle 101129103702-phpapp02
Aspnetpagelifecycle 101129103702-phpapp02
 
Why ASP.NET Development is Important?
Why ASP.NET Development is Important?Why ASP.NET Development is Important?
Why ASP.NET Development is Important?
 
As pnet pagelife_usha
As pnet pagelife_ushaAs pnet pagelife_usha
As pnet pagelife_usha
 
Server Controls of ASP.Net
Server Controls of ASP.NetServer Controls of ASP.Net
Server Controls of ASP.Net
 
Web forms in ASP.net
Web forms in ASP.netWeb forms in ASP.net
Web forms in ASP.net
 
Page life cycle
Page life cyclePage life cycle
Page life cycle
 
ASP.NET Session 6
ASP.NET Session 6ASP.NET Session 6
ASP.NET Session 6
 
Aspnet Life Cycles Events
Aspnet Life Cycles EventsAspnet Life Cycles Events
Aspnet Life Cycles Events
 
Web controls
Web controlsWeb controls
Web controls
 
M S Ajax Client Life Cycle Events
M S  Ajax  Client  Life  Cycle  EventsM S  Ajax  Client  Life  Cycle  Events
M S Ajax Client Life Cycle Events
 
Ajax and ASP.NET AJAX
Ajax and ASP.NET AJAXAjax and ASP.NET AJAX
Ajax and ASP.NET AJAX
 
React and Flux life cycle with JSX, React Router and Jest Unit Testing
React and  Flux life cycle with JSX, React Router and Jest Unit TestingReact and  Flux life cycle with JSX, React Router and Jest Unit Testing
React and Flux life cycle with JSX, React Router and Jest Unit Testing
 
ASP.NET Lecture 1
ASP.NET Lecture 1ASP.NET Lecture 1
ASP.NET Lecture 1
 
ASP.NET Lecture 2
ASP.NET Lecture 2ASP.NET Lecture 2
ASP.NET Lecture 2
 
State management 1
State management 1State management 1
State management 1
 
Intro react js
Intro react jsIntro react js
Intro react js
 
Flows - what you should know before implementing
Flows - what you should know before implementingFlows - what you should know before implementing
Flows - what you should know before implementing
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
 
Ajax
Ajax Ajax
Ajax
 

More from Sireesh K (20)

Cn10
Cn10Cn10
Cn10
 
chanakya neeti
chanakya neetichanakya neeti
chanakya neeti
 
chanakya neeti
chanakya neetichanakya neeti
chanakya neeti
 
What is mvc
What is mvcWhat is mvc
What is mvc
 
31c
31c31c
31c
 
31cs
31cs31cs
31cs
 
45c
45c45c
45c
 
44c
44c44c
44c
 
43c
43c43c
43c
 
42c
42c42c
42c
 
41c
41c41c
41c
 
40c
40c40c
40c
 
39c
39c39c
39c
 
38c
38c38c
38c
 
37c
37c37c
37c
 
35c
35c35c
35c
 
34c
34c34c
34c
 
33c
33c33c
33c
 
30c
30c30c
30c
 
29c
29c29c
29c
 

Recently uploaded

QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
httgc7rh9c
 

Recently uploaded (20)

Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Our Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdfOur Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdf
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 

Page life cycle IN ASP.NET

  • 3. Page request • The page request occurs before the page life cycle begins. When the page is requested by a user, ASP.NET determines whether the page needs to be parsed and compiled (therefore beginning the life of a page), or whether a cached version of the page can be sent in response without running the page. Life-Cycle Events Page request Start Initialization Load Postback event handling Rendering Unload
  • 4. Start • In the start stage, page properties such as Request and Response are set. At this stage, the page also determines whether the request is a postback or a new request and sets the IsPostBack property. The page also sets the UICulture property. Life-Cycle Events Page request Start Initialization Load Postback event handling Rendering Unload
  • 5. Initialization • During page initialization, controls on the page are available and each control's UniqueID property is set. • A master page and themes are also applied to the page if applicable. • If the current request is a postback, the postback data has not yet been loaded and control property values have not been restored to the values from view state. Life-Cycle Events Page request Start Initialization Load Postback event handling Rendering Unload
  • 6. Load • During load, if the current request is a postback, control properties are loaded with information recovered from view state and control state. Life-Cycle Events Page request Start Initialization Load Postback event handling Rendering Unload
  • 7. Postback event handling • If the request is a postback, control event handlers are called. After that, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page. (There is an exception to this sequence: the handler for the event that caused validation is called after validation.) Life-Cycle Events Page request Start Initialization Load Postback event handling Rendering Unload
  • 8. Rendering • Before rendering, view state is saved for the page and all controls. During the rendering stage, the page calls the Rendermethod for each control, providing a text writer that writes its output to the OutputStream object of the page's Responseproperty. Life-Cycle Events Page request Start Initialization Load Postback event handling Rendering Unload
  • 9. Unload • The Unload event is raised after the page has been fully rendered, sent to the client, and is ready to be discarded. • At this point, page properties such as Response and Request are unloaded and cleanup is performed. Life-Cycle Events Page request Start Initialization Load Postback event handling Rendering Unload
  • 10. PreInit • Raised after the start stage is complete and before the initialization stage begins. • Use this event for the following: • Check the IsPostBack property to determine whether this is the first time the page is being processed. The IsCallbackand IsCrossPagePostBack properties have also been set at this time. • Create or re-create dynamic controls. • Set a master page dynamically. • Set the Theme property dynamically. • Read or set profile property values. • To see the events execution order, create a new asp.net web project, and copy the following code. protected void Page_PreInit(object sender, EventArgs e) { Response.Write("Page_PreInit" + "<br/>"); } Life-Cycle Events PreInit Init InitComplete PreLoad Load Control events LoadComplete PreRender PreRenderComplete SaveStateComplete Render Unload
  • 11. Init • Raised after all controls have been initialized and any skin settings have been applied. The Init event of individual controls occurs before the Init event of the page. • Use this event to read or initialize control properties. • To see the events execution order, create a new asp.net web project, and copy the following code. • Protected void Page_Init(object sender, EventArgs e) { Response.Write("Page_Init" + "<br/>"); } Life-Cycle Events PreInit Init InitComplete PreLoad Load Control events LoadComplete PreRender PreRenderComplete SaveStateComplete Render Unload
  • 12. InitComplete • Raised at the end of the page's initialization stage. Only one operation takes place between the Init and InitComplete events: tracking 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. • Use this event to make changes to view state that you want to make sure are persisted after the next postback. • To see the events execution order, create a new asp.net web project, and copy the following code. • protected void Page_InitComplete(object sender, EventArgs e) { Response.Write("Page_InitComplete" + "<br/>"); } Life-Cycle Events PreInit Init InitComplete PreLoad Load Control events LoadComplete PreRender PreRenderComplete SaveStateComplete Render Unload
  • 13. Preload • Raised after the page loads view state for itself and all controls, and after it processes postback data that is included with theRequest instance. • To see the events execution order, create a new asp.net web project, and copy the following code. • protected void Page_PreLoad(object sender, Even tArgs e) {Response.Write("Page_PreLoad" + "<b r/>"); } Life-Cycle Events PreInit Init InitComplete PreLoad Load Control events LoadComplete PreRender PreRenderComplete SaveStateComplete Render Unload
  • 14. Load • The Page object calls the OnLoad method on the Page object, and then recursively does the same for each child control until the page and all controls are loaded. • The Load event of individual controls occurs after the Load event of the page. • Use the OnLoad event method to set properties in controls and to establish database connections. • To see the events execution order, create a new asp.net web project, and copy the following code. • protected void Page_LoadComplete(object sender, EventArgs e) { Response.Write("Page_LoadComplete" + "<br/>"); } Life-Cycle Events PreInit Init InitComplete PreLoad Load Control events LoadComplete PreRender PreRenderComplete SaveStateComplete Render Unload
  • 15. Control events • Use these events to handle specific control events, such as a Button control's Click event or a TextBox control's TextChangedevent. Life-Cycle Events PreInit Init InitComplete PreLoad Load Control events LoadComplete PreRender PreRenderComplete SaveStateComplete Render Unload
  • 16. PreRender • Raised after the Page object has created all controls that are required in order to render the page, including child controls of composite controls. (To do this, the Page object calls EnsureChildControls for each control and for the page.) • The Page object raises the PreRender event on the Page object, and then recursively does the same for each child control. ThePreRender event of individual controls occurs after the PreRender event of the page. • Use the event to make final changes to the contents of the page or its controls before the rendering stage begins. • To see the events execution order, create a new asp.net web project, and copy the following code. • protected void Page_PreRender(object sender, EventArgs e) { Response.Write("Page_PreRender" + "<br/>"); } Life-Cycle Events PreInit Init InitComplete PreLoad Load Control events LoadComplete PreRender PreRenderComplete SaveStateComplete Render Unload
  • 17. PreRenderComplete • Raised after each data bound control whose DataSourceID property is set calls its DataBind method. • To see the events execution order, create a new asp.net web project, and copy the following code. • protected void Page_PreRenderComplete(object sender, EventArgs e) { Response.Write("Page_PreRenderCom plete" + "<br/>"); } Life-Cycle Events PreInit Init InitComplete PreLoad Load Control events LoadComplete PreRender PreRenderComplete SaveStateComplete Render Unload
  • 18. SaveStateComplete • Raised after view state and control state have been saved for the page and for all controls. • Any changes to the page or controls at this point affect rendering, but the changes will not be retrieved on the next postback. • To see the events execution order, create a new asp.net web project, and copy the following code. • protected void Page_Unload(object sender, EventArgs e) { //Response.Write("Page_Unload" + "<br/>"); } Life-Cycle Events PreInit Init InitComplete PreLoad Load Control events LoadComplete PreRender PreRenderComplete SaveStateComplete Render Unload
  • 19. Render • This is not an event; instead, at this stage of processing, the Page object calls this method on each control. All ASP.NET Web server controls have a Render method that writes out the control's markup to send to the browser. • If you create a custom control, you typically override this method to output the control's markup. However, if your custom control incorporates only standard ASP.NET Web server controls and no custom markup, you do not need to override theRender method. For more information, see Developing Custom ASP.NET Server Controls. • A user control (an .ascx file) automatically incorporates rendering, so you do not need to explicitly render the control in code. • To see the events execution order, create a new asp.net web project, and copy the following code. Life-Cycle Events PreInit Init InitComplete PreLoad Load Control events LoadComplete PreRender PreRenderComplete SaveStateComplete Render Unload
  • 20. Unload • Raised for each control and then for the page. • In controls, use this event to do final cleanup for specific controls, such as closing control- specific database connections. • For the page itself, use this event to do final cleanup work, such as closing open files and database connections, or finishing up logging or other request-specific tasks. • To see the events execution order, create a new asp.net web project, and copy the following code. Life-Cycle Events PreInit Init InitComplete PreLoad Load Control events LoadComplete PreRender PreRenderComplete SaveStateComplete Render Unload
  • 21. Login Control Event LoggingIn • Raised during a postback, after the page's LoadComplete event has occurred. This event marks the beginning of the login process. • Use this event for tasks that must occur prior to beginning the authentication process. Authenticate • Raised after the LoggingIn event. • Use this event to override or enhance the default authentication behavior of a Login control. LoggingIn • Raised after the user name and password have been authenticated. • Use this event to redirect to another page or to dynamically set the text in the control. This event does not occur if there is an error or if authentication fails. LoginError • Raised if authentication was not successful. • Use this event to set text in the control that explains the problem or to direct the user to a different page.
  • 22. Leave feedback & question in the comments for our channel updates Hit on like button below For more visit our website www.sirykt.blogspot.com