Properties Inherited from Control and WebControl


Properties Inherited from Control and WebControl

In this section, we'll walk you through the properties that your control inherits from the base control classes.

Control Properties

The System.Web.UI.Control class defines properties that are essential for a server control to participate in the ASP.NET page framework. Table 7-1 lists the important public properties that every server control inherits from Control .

Table 7-1. Public Properties of the Control Class  

Public Property

Type

Description

ClientID

String

A unique identifier assigned to a control by the ASP.NET page framework and rendered as the HTML id attribute. We'll describe ClientID when we look at client-side scripting in Chapter 13, "Client-Side Behavior."

Controls

ControlCollection

The collection of a control's child controls in the control tree. We'll describe the Controls property in Chapter 12.

EnableViewState

Boolean

Specifies whether a control's state is persisted in view state across round-trips. We described EnableViewState earlier in this chapter in the section "Enabling View State."

ID

String

A user -supplied identifier for a control that is used to access the control. The page framework uses the ID value and the location of the control in the control tree to generate the ClientID and UniqueID properties.

NamingContainer

Control

The nearest control, upward in the control hierarchy, that implements the System.Web.UI.INamingContainer interface. We will describe NamingContainer in Chapter 12.

Page

Page

The page that contains the control.

Parent

Control

The control's parent control in the control tree. (Control A is a parent of control B if B belongs to A.Controls .) We'll describe Parent in Chapter 12.

UniqueID

String

The hierarchically qualified unique identifier assigned to a control by the page framework. We'll describe UniqueID in Chapter 12.

Visible

Boolean

Specifies whether the control should be rendered into the response stream when the page is ­rendered.

Table 7-2 describes the important protected properties that your control inherits from the Control class.

Table 7-2. Protected Properties of the Control Class

Protected Property

Type

Description

Context

HttpContext

Provides access to the System.Web.HttpContext object for the current Web request. The Context property allows a control to access other HTTP intrinsic objects, such as Application , Session , Request , and Response .

ViewState

StateBag

A dictionary of state information that is serialized and round-tripped across postbacks.

Appendix B, "Object Model for Key Classes," lists the complete object model for the Control class and provides an exhaustive list of all its properties.

WebControl Properties

You should derive your control from the System.Web.UI.WebControls.WebControl base class if you want to generate visible HTML elements. WebControl derives from Control and adds properties that enable a page developer to customize the appearance and behavior of the HTML element that is rendered by your control. These properties include strongly typed style properties such as Font , ForeColor , BackColor , and Width .

Table 7-3 lists the important public properties of WebControl .

Table 7-3. Public Properties Defined by the WebControl Class

Public Property

Type

Description

AccessKey

String

The keyboard shortcut key used to set focus on the rendered HTML element.

Attributes

AttributeCollection

A collection of custom name /value pairs rendered as attributes on the HTML element rendered by the control. We'll describe this property in Chapter 10.

BackColor

Color

The background color of the HTML element rendered by the control.

BorderColor

Color

The color of the border around the HTML element rendered by the control.

BorderStyle

BorderStyle

The border style of the HTML element rendered by the control, such as solid, double, or dotted .

BorderWidth

Unit

The thickness of the border around the HTML element rendered by the control.

ControlStyle

Style

The strongly typed style of the control that encapsulates all its appearance- related functionality. We'll describe ControlStyle in Chapter 11, "Styles in Controls." The type of Control ­Style is a class that derives from System.Web.UI.Web ­Controls.Style , which exposes properties such as Font , Width , BackColor , and ForeColor .

CssClass

String

The CSS class rendered by the control on the client. Page developers can use this property to associate the rendered element with style attributes declared in a style sheet.

Enabled

Boolean

Specifies whether the HTML element rendered by a Web server control is enabled. Typically, an HTML element that is not enabled is dimmed in the Web browser and cannot receive input focus.

Font

FontInfo

The font used to display the text within the HTML element rendered by the control.

ForeColor

Color

The foreground color of the text within the HTML element rendered by the control.

Height

Unit

The height of the HTML element rendered by the control.

ToolTip

String

The text shown in the ToolTip that is displayed when the cursor is situated over the HTML element rendered by the control.

Width

Unit

The width of the HTML element rendered by the control.

Table 7-4 lists the protected properties that your control inherits when you derive from WebControl .

Table 7-4. Protected Properties of the WebControl Class

Protected Property

Type

Description

TagKey

HtmlTextWriterTag

Override this property to render a standard HTML tag that is included in the System.Web.UI.HtmlTextWriterTag enumeration instead of the default < span > tag that WebControl renders .

TagName

String

Override this property to render a nonstandard HTML tag (one that is not included in the System.Web.UI.HtmlTextWriterTag enumeration) instead of the default < span > tag.

Appendix B lists the complete object model for the WebControl class and provides an exhaustive list of all its properties.



Developing Microsoft ASP. NET Server Controls and Components
Developing Microsoft ASP.NET Server Controls and Components (Pro-Developer)
ISBN: 0735615829
EAN: 2147483647
Year: 2005
Pages: 183

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net