The Style class encapsulates the properties that control the appearance of a Web server control and can be applied to multiple Web server controls to provide a common appearance. Web developer can determine the background color and font color of a control by setting the BackColor and ForeColor properties, respectively. On controls that can display a border, Web developer can control the border width, the border style, and the border color by setting the BorderWidth, BorderStyle, and BorderColor properties. The size of a Web server control can also be specified by using the Height and Width properties.

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

Property

Description

Supported in .NET version

BackColor

The property is used to set or get the background color of the Web server control. Software developer can set it using a System.Drawing..::.Color object.

1.0,1.1, 2.0, 3.0, 3.5, 4.0

BorderColor

The property is used to set or get the border color of the Web server control. Software developer can set it using a System.Drawing..::.Color object.

1.0,1.1, 2.0, 3.0, 3.5, 4.0

BorderStyle

The property is used to set or get the border style of the Web server control. Software developer can choose one of the values from the BorderStyle enumeration – Dashed, Dotted, Double, Grrove, Ridge, Inset, Outset, Solid and None.

1.0,1.1, 2.0, 3.0, 3.5, 4.0

BorderWidth

The property is used to set or get the border width of the Web server control.  When software developer sets this property he/she should use combination of a numeric value followed by type of measurement: px (for pixels) or % (for percentage) and so on.

1.0,1.1, 2.0, 3.0, 3.5, 4.0

CanRaiseEvents

Returns a true value if the component can raise an event. Its default value is true. Note: If Web developer overrides this method in a deriving class and change it to return false, the EventHandlerList collection returned by the Events property returns a null reference (Nothing in VB.NET) for an event. Events can still be added and removed from the collection, but the collection’s Item property will always return a null reference (Nothing in VB.NET).

2.0, 3.0, 3.5, 4.0

Container

This property returns the IContainer that contains the Component if any, or a null reference (Nothing in VB.NET) if the Component is not encapsulated in an IContainer. The components in a container are tracked in a first-in, first-out list, which also defines the order of the components within the container.

1.0,1.1, 2.0, 3.0, 3.5, 4.0

CssClass

Software developer can use this property to specify the CSS class to render on the client for the Web Server control. This property will render on browsers for all controls. On browsers that do not support CSS, setting the CssClass property will have no effect.

1.0,1.1, 2.0, 3.0, 3.5, 4.0

DesignMode

This property returns true to indicate that the control is being used in the context of a designer. Software developer’s custom controls can use this property when design-time behavior is different than run-time behavior.

2.0, 3.0, 3.5, 4.0

Events

This read-only property returns a list of event handler delegates for the control. The type of this property is EventHadlerList, which uses a linear search algorithm to find entries in the list of delegates. When the list of delegates is large, finding entries with this property will be slow, because a linear search algorithm is inefficient when working with a large number of entries.

1.0,1.1, 2.0, 3.0, 3.5, 4.0

Font

Software developer can use this property to specify the font properties of the Web Server control. This property includes subproperties that can be accessed declaratively in the form of Property-Subproperty (for example Font-Bold) or programmatically in the form of Property.Subproperty (for example Font.Bold).

All but one subproperty will render in browsers prior to Microsoft Internet Explorer version 4 for all controls. They are: Bold, Italic, Name, Names, Strikeout, Underline, and Size (but only named font sizes, such as Small, Smaller, and so on, will work).

 

1.0,1.1, 2.0, 3.0, 3.5, 4.0

ForeColor

Software developer can use this property to to specify the foreground color of the Web server control. The foreground color is usually the color of the text. This property will render on browsers earlier than Microsoft Internet Explorer version 4 for all controls, except the Image, AdRotator, HyperLink and LinkButton.

1.0,1.1, 2.0, 3.0, 3.5, 4.0

Height

This property is used to specify the height of the Web server control. When software developer sets this property he/she should use combination of a numeric value followed by type of measurement: px (for pixels) or % (for percentage) and so on.This property does not render for all controls in browsers earlier than Microsoft Internet Explorer version 4. Controls that do not render this property in earlier browsers include Label, HyperLink, LinkButton, and any validation controls. The CheckBoxList, RadioButtonList and DataList also do not render this property in earlier browsers when their RepeatLayout property is set to RepeatLayout.Flow. Furthermore, only unit types of Pixel and Percentage are supported in earlier browsers.

1.0,1.1, 2.0, 3.0, 3.5, 4.0

IsEmpty

A protected property. Returns a value indicating whether any style elements have been defined in the state bag. Its return true if the state bag has no style elements defined; otherwise, false.

1.0,1.1, 2.0, 3.0, 3.5, 4.0

IsTrackingViewState

This property returns value true if the control is marked to save changes to its view state; otherwise, false.

 

1.0,1.1, 2.0, 3.0, 3.5, 4.0

RegisteredCssClass

This property is used to get the cascading style sheet (CSS) class that is registered with the control.

2.0, 3.0, 3.5, 4.0

Site

Using this property software developer can get information about the container that hosts the current control when rendered on a design surface.  A site binds a Component object to a Container object and enables communication between the two. It also provides a way for the container to manage its components.

1.0,1.1, 2.0, 3.0, 3.5, 4.0

ViewState

Web developers can use this property to get a dictionary of state information that allows them to save and restore the view state of a server control across multiple requests for the same page.

1.0,1.1, 2.0, 3.0, 3.5, 4.0

Width

This property is used to specify the width of the Web server control. When software developer sets this property he/she should use combination of a numeric value followed by type of measurement: px (for pixels) or % (for percentage) and so on.This property does not render for all controls in browsers earlier than Microsoft Internet Explorer version 4. Controls that do not render this property in earlier browsers include Label, HyperLink, LinkButton, and any validation controls. The CheckBoxList, RadioButtonList and DataList also do not render this property in earlier browsers when their RepeatLayout property is set to RepeatLayout.Flow. Furthermore, only unit types of Pixel and Percentage are supported in earlier browsers.

1.0,1.1, 2.0, 3.0, 3.5, 4.0