System.Web.UI.WebControls.WebControl Class

Serves as the base class that defines the methods, properties and events common to all controls in the System.Web.UI.WebControls namespace.

See Also: WebControl Members


[System.Web.UI.PersistChildren(false, false)]
public class WebControl : System.Web.UI.Control, System.Web.UI.IAttributeAccessor


The System.Web.UI.WebControls.WebControl class provides the properties, methods, and events that are common to all Web server controls. You can control the appearance and behavior of a Web server control by setting properties defined in this class. For example, the background color and font color of a control are controlled by using the WebControl.BackColor and WebControl.ForeColor properties, respectively. On controls that can display a border, you can control the border width, the border style, and the border color by setting the WebControl.BorderWidth, WebControl.BorderStyle, and WebControl.BorderColor properties. The size of a Web server control can be specified by using the WebControl.Height and WebControl.Width properties.

The behavior of the control can be specified by setting certain properties. You can enable and disable a control by setting the WebControl.Enabled property. The place of the control in the tab order is controlled by setting the WebControl.TabIndex property. You can specify a ToolTip for the control by setting the WebControl.ToolTip property.


Not all controls support every property defined in this class. For specific information about whether a property is supported, see the documentation for the specific control.


Some properties in this class render differently, depending on the browser. Some properties do not render at all, while others render, but have no effect. The System.Web.Configuration.HttpCapabilitiesBase.TagWriter property of the System.Web.HttpBrowserCapabilities object determines the way in which a Web server control renders. For browsers that support HTML 4.0, the System.Web.Configuration.HttpCapabilitiesBase.TagWriter property will contain a regular System.Web.HttpBrowserCapabilities object, and most properties will be rendered using HTML 4.0 style attributes. Browsers that are not known to support HTML 4.0 will use the System.Web.UI.Html32TextWriter object. This will automatically map the style attributes to any relevant HTML 3.2 tag attributes. In some cases, such as with the WebControl.ForeColor property, the style attributes will be converted into additional tags, such as <font> tags. In some cases, there will be no mapping performed. For specific information about how a property is rendered in different browsers, see the documentation for the specific property.

For a list of initial property values for an instance of System.Web.UI.WebControls.WebControl, see the WebControl.#ctor constructor.


Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0,