Here you will see how an ASP.NET page renders after requesting it.
What is ASP.NET?
ASP.NET is a Microsoft technology that provides us a platform where we can create and build web applications. ASP.NET uses server side control and render as html. Using ASP.NET, we can create wide range of big enterprise web application. When we request for an ASP.NET page through browser, then it goes through different stages and this is called ASP.NET page life cycle.
Page Life Cycle
ASP.NET page life cycle describes us how an ASP.NET page renders page control, how it renders in the browser, which type of events fire during the processing of the page.
When you make a request for a page, it loads into the server memory and processes it and sends the result to the browser which render as html on the browser. During from page request to page render, different method and events are fired according to the application.
Stages of Page Life Cycle
- Page Initialization
- Page Load
- Page Render
- Page Unload
In this stage the following events are fired.
It is a first event of life cycle. We can say it is the entry point of page life cycle. It is raised before the start page initialization. Here you can check page is loaded first time or not using the IsPostBack property. You can create dynamic controls here and set the master page and themes here.
It is called after all the controls initialization and skins have been set for the page. The Init event of individual control calls before the Init event of page.
This is used to track the view state. This events fire after all page and control initializations complete. Here we can manipulate the view state if it is set or not.
This is raised before the post back data of control.
The load event is triggered first for page and after that their controls. It is raised for all child controls recursively. We can use OnLoad event to set the properties of control and database connection.
This event is called after completing the page load and page child control load. The control event handlers are run. This event can be handled by using OnLoadComplete method.
When page is going to render, the PreRender event is raised just before the output renders. We can perform any task on control before the output is going to render.
This event is raised when page is going to render on browser. This is basically a cleanup task like closing and disposing the database connection. It is raised first for each control and then for page.
See the following Microsoft image, which shows you how an ASP.NET page render and which events fired in process of page life cycle.
Thanks for reading this article. Hope this will help you.