Skip to main content

What is page life cycle in ASP.NET 2.0 ?

Refernce from:- http://www.dotnetuncle.com/aspnet/71_page_life_cycle.aspx

ASP.NET 2.0 Page Life Cycle - The lifetime of an ASP.NET page is filled with events. A .NET technical interview might begin with this question. A series of processing steps takes place during this page life cycle. Following tasks are performed:

1) Initialization
2) Instantiation of controls
3) Restoration & Maintainance of State
4) Running Event Handlers
5) Rendering of data to the browser

The life cycle may be broken down into Stages and Events. The stages reflect the broad spectrum of tasks performed. The following stages take place

1) Page Request - This is the first stage, before the page life cycle starts. Whenever a page is requested, ASP.NET detects whether the page is to be requested, parsed and compiled or whether the page can be cached from the system.
2) Start - In this stage, properties such as Request and Response are set. Its also determined at this stage whether the request is a new request or old, and thus it sets the IsPostBack property in the Start stage of the page life cycle.
3) Page Initialization - Each control of the page is assigned a unique identification ID. If there are themes, they are applied. Note that during the Page Initialization stage, neither postback data is loaded, nor any viewstate data is retrieved.
4) Load - If current request is a postback, then control values are retrieved from their viewstate.
5) Validation - The validate method of the validation controls is invoked. This sets the IsValid property of the validation control.
6) PostBack Event Handling - Event handlers are invoked, in case the request is a postback.
7) Rendering - Viewstate for the page is saved. Then render method for each control is called. A textwriter writes the output of the rendering stage to the output stream of the page's Response property.
8) Unload - This is the last stage in the page life cycle stages. It is invoked when the page is completely rendered. Page properties like Respone and Request are unloaded.

Note that each stage has its own events within it. These events may be used by developers to handle their code. Listed below are page events that are used more frequently.

PreInit - Checks the IsPostBack property. To create or recreate dynamic controls. To set master pages dynamically. Gets and Sets profile propety values.
Init - Raised after all controls are initialized, and skin properties are set.
InitComplete - This event may be used, when we need to be sure that all initialization tasks are complete.
PreLoad - If processing on a control or a page is required before the Load event.
Load - invokes the OnLoad event on the page. The same is done for each child control on the page. May set properties of controls, create database connections.
Control Events - These are the control specific events, such as button clicks, listbox item selects etc.
LoadComplete - To execute tasks that require that the complete page has been loaded.
PreRender - Some methods are called before the PreRenderEvent takes place, like EnsureChildControls, data bound controls that have a dataSourceId set also call the DataBind method.
Each control of the page has a PreRender event. Developers may use the prerender event to make final changes to the controls before it is rendered to the page.
SaveStateComplete - ViewState is saved before this event occurs. However, if any changes to the viewstate of a control is made, then this is the event to be used. It cannot be used to make changes to other properties of a control.
Render - This is a stage, not an event. The page object invokes this stage on each control of the page. This actually means that the ASP.NET server control's HTML markup is sent to the browser.
Unload - This event occurs for each control. It takes care of cleanup activities like wiping the database connectivities.

Comments

Popular posts from this blog

Creating Simple Cascading DropDownList In ASP.NET Core MVC With New Tag Helpers

Topic Database part Creating application Installing Package for Entity framework core From NuGet Adding Connection string and Setting up DbContext Adding Category, SubCategory, MainProduct Model in Models Folder Adding DbSet for Category, SubCategory, and MainProduct Model in DatabaseContext class Adding Controller [DemoController] Getting Data from Database using Entity framework core. Adding View [index.cshtml] Binding Category Dropdownlist using new Tag helper Adding SubCategory and Product Dropdownlist to index.cshtml View Adding SubCategory and GetProducts Action Method to Demo Controller Adding Jquery reference on View and Default items in drop-down list Binding SubCategory and Product drop-down list with jquery Ajax Adding Index Action method for handling post request and getting selected values Saving and Run Application Read Entire Article on below link :- http://www.c-sharpcorner.com/article/creating-simple-cascading-dropdownlist-in-asp-net-core-mvc-with-

Capturing Image From Web Cam in ASP.Net MVC

This article shows how to capture an image using a webcam in MVC4 and in this application we will use a jQuery webcam.js plug-in for capturing images. I have seen that most online applications currently require webcam image capturing functionality in some way or another. Most social networking sites use this kind of functionality in their application for capturing user profile pictures. To see Complete Article Visit: -  http://www.c-sharpcorner.com/UploadFile/4d9083/capturing-image-from-web-cam-in-Asp-Net-mvc139/ Agenda Create basic MVC application. Download and Adding webcam.js related reference files to project. Adding Controller ( PhotoController ). Adding Index view. Adding Action Method Capture( ). Adding Script for capturing Image. Adding Action Method and Script for binding image. Adding [HttpPost] Index Action Method. Displaying the index View in New Window. Changephoto.cshtml Code Snippet. PhotoController Code Snippet. Index.cshtml Code Snip

Spire.Office for .NET

Introduction Free Spire.Doc for .NET is a Community Edition of the Spire.Doc for .NET, which is a totally free word component for commercial and personal use. As a free C#/VB.NET component, it also offers a lot of powerful functions. Developers can use it to generate, read, write, save, print and convert documents on any .NET applications. The featured function, conversion allows converting Word documents (Word 97-2003, Word 2007, Word 2010, word 2013) to commonly used file format, such as XML, RTF, TXT, PDF, XPS, EPUB, HTML and Image etc. Visit Site for Details :-  Click Here to Visit Official Site     Click here to Download Tools :- Download Here In this article we are going to learn how to generate DOC file Use Powerful tool Spire.Office for .NET Tool Required We are using Visual Studio 2012. Free Spire.Office Component [Free for commercial and personal use] Support .Net from [ 2.0 to 4.5 ] Getting Started Let’s start with creating a new project