JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Immediate Solutions: Using the System.Web.UI.Page Class

Any Web page requested from a server hosting the .NET framework, whether it contains .NET code or only HTML text, is actually based on the System.Web.UI.Page class; this is the class that our Web forms inherit from:

Public Class WebForm1
    Inherits System.Web.UI.Page
       

Here is the class hierarchy for the Page class (note that the Control class here is the ASP .NET Control class, not the Windows application's Control class):

Object
   Control
      TemplateControl
         Page

You can find the notable public properties of Page objects in Table 14.5, the notable methods in Table 14.6, and the notable events in Table 14.7. Note that I'm not including all the properties, methods, and events that the Page class inherits from the System.Web.UI.Control class—you can find them in Chapter 15, Tables 15.1, 15.2, and Tables 15.3. (The Page class doesn't inherit members from the TemplateControl class that you normally deal with directly.)

Table 14.5: Noteworthy public properties of Page objects.

Property

Means

Application

Gets an Application object.

ClientTarget

Gets/sets if you want to override automatic browser capabilities detection and handle page rendering for specific browsers.

ErrorPage

Gets/sets an error page's URL in case there are unhandled page exceptions.

IsPostBack

Indicates if a page was created after a client postback, or if it is being loaded for the first time.

IsValid

Indicates if a page validation was successful.

Request

Gets the current HTTP Request object.

Response

Gets the current HTTP Response object.

Server

Gets the current Server object.

Session

Gets the current Session object.

Site

Gets Web site data.

User

Gets data about the user.

Validators

Gets a collection of the validation controls in the page.

Table 14.6: Noteworthy public methods of Page objects.

Method

Means

HasControls

Indicates if the form has any child controls.

LoadControl

Gets a UserControl object.

MapPath

Connects a virtual path to an actual path.

ResolveUrl

Converts a relative URL to an absolute URL.

Validate

Validates data using validation control in the page.

Table 14.7: Noteworthy public events of Page objects.

Event

Means

Disposed

Occurs when a Web form is disposed.

Error

Occurs when an unhandled exception has occurred.

Init

Occurs when the Web form is initialized.

Load

Occurs when the Web form is loaded.

Unload

Occurs when the server control is unloaded.

Previous Section Next Section




JavaScript Editor Free JavaScript Editor     JavaScript Editor