Introduction to ASP.NET

Introduction to ASP.NET

07 Jun 2024
3 min read

According to Microsoft, "ASP.NET is a technology for building powerful, dynamic Web applications and is part of the .NET Framework". In fact, ASP.NET is a programming framework used to develop web applications and web services. Basically, it is the next version of ASP. You can also read brief version history of ASP.NET in past article. It provides the easy way to build, deploy & run the web application on any browser.

Benefits of Asp.Net

  1. ASP.NET makes development simple and easy to maintain with event-driven and server side programming model.

  2. 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.

  3. ASP.NET provides validations controls.

  4. 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.

  5. 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 :

  1. PreInit

    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.

  2. Init

    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.

  3. InitComplete

    This indicates that page is completely initialised.

  4. Preload

    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.

  5. Load

    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.

    ASP.NET Page Life Cycle Events


  6. loadComplete

    This indicates that page is completely loaded into memory.

  7. Prender

    we use this event to make final changes to the controls or page before rendering it to the browser.

  8. SaveStateComplete

    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.

  9. Render/PrenderComplete

    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.

  10. 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.We can use this event for closing files & database connection. This event occurs for each control.

Share Article
About Author
Shailendra Chauhan (Microsoft MVP, Founder & CEO at Scholarhat by DotNetTricks)

Shailendra Chauhan is the Founder and CEO at ScholarHat by DotNetTricks which is a brand when it comes to e-Learning. He provides training and consultation over an array of technologies like Cloud, .NET, Angular, React, Node, Microservices, Containers and Mobile Apps development. He has been awarded Microsoft MVP 8th time in a row (2016-2023). He has changed many lives with his writings and unique training programs. He has a number of most sought-after books to his name which has helped job aspirants in cracking tough interviews with ease.
Accept cookies & close this