This documentation is archived and is not being maintained.

CssStyleCollection.Item Property (String)

Gets or sets the specified CSS value for the HTML server control.

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

public string this[
	string key
] { get; set; }


Type: System.String

The index to the CSS attribute.

Property Value

Type: System.String
The value of key.

The following code example uses the Item property to return the value of a style that is set on a HtmlInputText control.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<script runat="server">

  protected void Page_Load(object sender, EventArgs e)
    MyText.Style.Add(HtmlTextWriterStyle.Width, "200");
    FirstMessage.Text = "The text box font color is: " + 
      MyText.Style["color"] + "<br />" +
      "The text box width is: " + 

<html xmlns="" >
<head runat="server">
    <title>CssCollection This Example</title>
    <form id="form1" runat="server">
      <input id="MyText"
             value="Type a value here."
             style="font: 14pt Verdana; color: blue;"
      <br />
      <asp:Label id="FirstMessage"

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