CssStyleCollection Class
Contains the HTML cascading-style sheets (CSS) inline style attributes for a specified HTML server control. This class cannot be inherited.
Assembly: System.Web (in System.Web.dll)
The CssStyleCollection type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | Count | Gets the number of items in the CssStyleCollection object. |
![]() | Item[HtmlTextWriterStyle] | Gets or sets the specified HtmlTextWriterStyle value for the HTML server control. |
![]() | Item[String] | Gets or sets the specified CSS value for the HTML server control. |
![]() | Keys | Gets a collection of keys to all the styles in the CssStyleCollection object for a specific HTML server control. |
![]() | Value | Gets or sets the value of the style attribute of the HTML server control. |
| Name | Description | |
|---|---|---|
![]() | Add(HtmlTextWriterStyle, String) | Adds a style item to the CssStyleCollection collection of a control using the specified HtmlTextWriterStyle enumeration value and corresponding value. |
![]() | Add(String, String) | Adds a style item to the CssStyleCollection of a control using the specified name/value pair. |
![]() | Clear | Removes all style items from the CssStyleCollection object. |
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | Remove(HtmlTextWriterStyle) | Removes a style item from the CssStyleCollection collection of a control using the specified HtmlTextWriterStyle enumeration value. |
![]() | Remove(String) | Removes a style item from the CssStyleCollection of a control using the specified style key. |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
Any style declared for a particular HTML server control is added to the collection when the containing Web Forms page is parsed. It automatically parses and exposes CSS properties through a dictionary pattern API. You can manipulate any CSS property on a server control through the Style property. Simply use the CSS property's key and value in the indexed collection.
The following code example iterates through the CssStyleCollection object for an HtmlInputText server control. The Keys property is used to determine which style attributes have been declared on the server control, and then binds the attribute names and values to a DataList object on the Web Forms page.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.


