Share via


Base Web Server Control Properties

The properties listed in the following table apply to all Web server controls that derive from the WebControl class. Web server controls that do not inherit from the WebControl class include Literal, PlaceHolder, Repeater, and Xml.

Properties

AccessKey The control's keyboard shortcut key (AccessKey). It specifies a single letter or number that the user can press while pressing ALT. For example, specify "K" if you want the user to press ALT+K to access the control. Shortcut keys are supported only in Internet Explorer 4.0 and later versions.
Attributes The collection of additional attributes on the control not defined by a public property, but that should also be rendered. Any attribute that is not defined by the Web server control is added to this collection. This allows you to use an HTML attribute that is not directly supported by the control.
Note   This property is used only when programming; it cannot be set when declaring the control.
BackColor The background color of the control. The BackColor property can be set using standard HTML color identifiers: the name of a color ("black" or "red") or an RGB value expressed in hexadecimal format ("#ffffff").
BorderColor The border color of the control. The BorderColor property can be set using standard HTML color identifiers: the name of a color ("black" or "red") or an RGB value expressed in hexadecimal format ("#ffffff").
BorderWidth The width of the control's border (if any) in pixels.
Note   This property might not work for all controls in browsers earlier than Internet Explorer 4.0.
BorderStyle The control's border style, if any. The possible values are:
  • NotSet
  • None
  • Dotted
  • Dashed
  • Solid
  • Double
  • Groove
  • Ridge
  • Inset
  • Outset
CssClass The cascading style sheets (CSS) class to assign to the control.
Style A collection of text attributes that are rendered as a CSS style attribute on the outer tag of the control.
Note   Any style values set using style properties (for example, BackColor) will automatically override a corresponding value in this collection. Values set using this property are not automatically reflected in the strongly typed style properties.

Some controls support style objects that allow you to apply style properties to individual elements of the control. Those properties override any settings you make using the Style property.

Enabled Makes the control functional when this property is set to true (the default). Disables the control when this property is set to false.
Note   Disabling a control dims the control and makes it inactive. It does not hide the control.
Font Provides font information for the Web server control that you are declaring. This property includes subproperties that you can declare using the property-subproperty syntax in the opening tag of a Web server control element. For example, you can make a Web server control's text bold by including the Font-Bold attribute in its opening tag.
ForeColor The foreground color of the control.
Note   This property might not work for all controls in browsers earlier than Internet Explorer 4.0.
Height The control's height.
Note   This property might not work for all controls in browsers earlier than Internet Explorer 4.0.
TabIndex The control's position in the tab order. If this property is not set, the control's position index is 0. Controls with the same tab index are moved to according to the order in which they are declared in the Web page.
Note   This property only works in Microsoft Internet Explorer 4.0 and later.
ToolTip The text that appears when the user rests the mouse pointer over a control.
Note   The ToolTip property does not work in all browsers. Check with the browser for compatibility.
Width The fixed width of the control. The possible units are:
  • Pixel
  • Point
  • Pica
  • Inch
  • Mm
  • Cm
  • Percentage
  • Em
  • Ex

    Note   The default unit is pixels. Not all browsers support every unit type.

See Also

Web Server Controls | System.Web.UI.WebControls Namespace