Introduction to Asp.net
According to Microsoft, "ASP.NET is a technology for building powerful, dynamic Web applications and is part of the .NET Framework". Infact Asp.Net is a programming framework used to develop web applications and web services. Basically it is next version of asp. It provides the easy way to build, deploy & run web application on any browser.
Benefits of Asp.Net
Asp.Net makes development simple and easy to maintain with event-driven and server side programming model.
Asp.Net source code is executed on the server. The source code is complied first time the page is requested. The server serves the complied version of the page for use next time the page is requested.
Asp.Net provides validations controls.
The html produced by Asp.Net is sent back to the browser. The application code that we write is not sent back to the browser and is not stolen easily.
In Asp.Net business logic(in .cs class file) and presentation logic(in .aspx file) are in separate files.
Asp .Net Page Life Cycle Events
At each stage of the page life cycle, the page raises some events, which could be coded. An event handler is basically a function or subroutine, bound to the event, using declarative attributes like Onclick or handle. Asp.Net 3.5 & 4.0 page life cycle has following events in sequence :
It is is entry point of page life cycle. It checks IsPostBack property to check or recreate dynamic controls. In this we can set master pages dynamically & set and get profile property values.
It is is raised after all controls of page are initilised and skin properties are set. It is used to read or initialise control properties.
This indicates that page is completely initialised.
This event is called before loading the page in the RAM(memory). If any processing on a control or on page is required we use it.
This invokes the onload event of the page. In this we create connection to the database, get/set controls values and get/set view state values.
This indicates that page is completely loaded into memory.
we use this event to make final changes to the controls or page before rendering it to the browser.
View state of each control is saved before this event occurs. If we want to change the view state of any control then we use this event. This event can not be used to change the other properties of the controls.
This indicates that page is completely rendered to the browser.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.
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.We can use this event for closing files & database connection. This event occurs for each control.