O'Reilly logo

ASP.NET in a Nutshell by Matthew MacDonald, G. Andrew Duthie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 12. The Page Class

In contrast to classic ASP, ASP.NET features a far richer object model that allows virtually every part of an ASP.NET application to be generated and modified dynamically. Central to this ability to generate -- and particularly, to modify -- content programmatically is the Page class, which is new to ASP.NET.

The Page class (or a class derived from the Page class) represents a request to an .aspx page that is processed by the ASP.NET extension to Internet Information Server or to another web server supporting the .NET Framework. The web page may contain simple HTML and text, .NET code, or a combination of both; in other words, the Page class represents a single Web Forms page. The requests for that page are served by the compiled object that sends HTML or other content back to the client.

The Page object is recompiled if any source files that form this page, such as a user control, a code-behind file, the .aspx page itself, or the application configuration file, are changed.

In the case of single-file ASP.NET pages (i.e., .aspx files that combine user interface elements with script), the .aspx page is compiled into an instance of a class that derives directly from the Page class. This is evident from the following code:

Public Sub Page_Load(o AS Object, e AS EventArgs)
   Dim oType As Type
   oType = Me.GetType
   Do
      Response.Write(oType.Name & "<BR />")
      oType = oType.BaseType
   Loop While Not oType Is Nothing
End Sub

The output produced by this code appears as follows: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required