Name

Page

Synopsis

All Web Forms you create for an ASP.NET application derive implicitly or explicitly from Page. This class, which is a special subclass of Control, adds additional page-specific functionality. For example, rather than simply providing the Control.Context property, the Page class provides the traditional built-in objects through references like Response, Request, and Application. The Page class also provides properties that allow you to use tracing (Trace and TraceEnabled) and access all the validation controls and information about whether their validation was successful (Validators and IsValid).

Another useful property is IsPostBack, which you can test in the Load event. Typically, you will skip control initialization if this property returns True, indicating that the page has already been displayed and the control values will be persisted in view state. You can also set AspCompatMode to True so the Page will be executed on a single-threaded apartment (STA) thread. This setting allows the page to call other STA components, such as those you may have developed with Visual Basic 6 (although it can hamper performance significantly).

Most Page methods are used by the ASP.NET framework and will never be used in your code. One exception is MapPath(), which returns the physical path on the server that corresponds to a specified virtual path (URL).

Public Class Page : Inherits TemplateControl : Implements System.Web.IHttpHandler
' Public Constructors
   Public Sub New

Get ASP.NET in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.