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

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

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