JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

The Control Class

The System.Web.UI.Control class is the base class for Web server controls, and for the Web form Page class as well. This class is derived directly from the Object class:

Object
   Control

You can find the notable public properties of Control objects in Table 15.1, the notable methods in Table 15.2, and the notable events in Table 15.3. These tables are worth a look, because they list many of the properties, methods, and events we'll be using with server controls. It's worth noting the EnableViewState property, which specifies if the control saves its state between round trips to the server (the default setting for this property is True). Note also the Init and Load events, which you can use to initialize your controls.

Table 15.1: Noteworthy public properties of Control objects.

Property

Means

ClientID

Gets the ASP.NET control identifier for the control.

Controls

Gets a collection of child controls in the control.

EnableViewState

Gets/sets whether the control maintains its state between round trips to the server.

ID

Gets/sets the ID for the control.

Page

Gets the Page object that contains the control.

Parent

Gets the control's parent control.

Site

Gets the control's Web site.

UniqueID

Gets the unique ID for the control.

Visible

Gets/sets whether the control is visible or not.

Table 15.2: Noteworthy public methods of Control objects.

Method

Means

DataBind

Binds the control to a data source.

Dispose

Disposes of the control.

FindControl

Searches a container for a control.

HasControls

True if the control contains child controls.

RenderControl

Draws the control, using HTML.

ResolveUrl

Resolves relative URLs to absolute URLs, based on the location of the control's containing page.

Table 15.3: Noteworthy public events of Control objects.

Event

Means

DataBinding

Occurs when data source is bound to a control.

Disposed

Occurs when a control is disposed of.

Init

Occurs when a control is initialized (this is the first event you can use for controls).

Load

Occurs when a control is loaded into a Page object.

PreRender

Occurs when a control is about to be drawn in a Page object.

Unload

Occurs when a control is unloaded.

In fact, there's another class to discuss here, because Web server controls aren't based directly on the Control class-they are based on the WebControl class, which is based on the Control class.

Previous Section Next Section




JavaScript Editor Free JavaScript Editor     JavaScript Editor