ASP.NET - SPLessons

ASP.NET Page Class Overview

Home > Lesson > Chapter 4
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

ASP.NET Page Class Overview

ASP.NET Page Class Overview

shape Description

When an ASP.NET page is requested and renders markup to a browser, ASP.NET creates an instance of a class that represents page. This class is composed of the code, that the developer wrote as well as the code generated by ASP.NET. ASP.NET page runs as a unit combining the server-side elements in a page, such as controls, with event-handling code that is written.

Code Behind Model

shape Description

The page’s mark up and server side elements with control declarations are in .aspx file, which is the code-behind model, while page code is a separate file. Code file contains a partial class, which is a class declaration with the keyword partial including that it contains some of the total code, that make up the full class for the page. Here developer can add the required code for the page. Mainly it consists of event handlers, but it can include other methods and properties too. In Visual Studio, under Solution Explorer one can see the .aspx file and under .aspx there is one .aspx.cs file and one .aspx.designer.cs file.

shape Conceptual figure

Please find how .aspx and .aspx.cs interacts in the following diagram.