This documentation is archived and is not being maintained.

WebControl.Style Property

Gets a collection of text attributes that will be rendered as a style attribute on the outer tag of the Web server control.

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

No code example is currently available or this language may not be supported.

Property Value

Type: System.Web.UI.CssStyleCollection
A CssStyleCollection that contains the HTML style attributes to render on the outer tag of the Web server control.

Use the Style collection to manage the style attributes rendered in the outer tag of the Web server control. This property will render on all browsers for all controls.

NoteNote:

Browsers that do not support style attributes will ignore the rendered HTML.

Any style values set through the strongly typed style properties (for example, BackColor="Red") will automatically override a corresponding value in this collection.

Values set in this collection are not automatically reflected by the strongly typed style properties.

The following example illustrates how to use the Style property to hide or display a Label control on a page.

NoteNote:

The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see ASP.NET Web Page Code Model.

No code example is currently available or this language may not be supported.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Show: