Style.CssClass 屬性


取得或設定用戶端上 Web 伺服器控制項所呈現的階層式樣式表 (CSS)。Gets or sets the cascading style sheet (CSS) class rendered by the Web server control on the client.

 property System::String ^ CssClass { System::String ^ get(); void set(System::String ^ value); };
public string CssClass { get; set; }
member this.CssClass : string with get, set
Public Property CssClass As String



用戶端上 Web 伺服器控制項所呈現的 CSS 類別。The CSS class rendered by the Web server control on the client. 預設為 EmptyThe default is Empty.


CssClass 可以使用屬性來指定要在 Web 服務器控制項的用戶端上呈現的 CSS 類別。Use the CssClass 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. 無論瀏覽器為何,它一律會轉譯為 class 屬性。It will always be rendered as the class attribute, regardless of the browser.

例如,假設您有下列 Web 服務器控制項宣告:For example, suppose you have the following Web server control declaration:

<asp:TextBox id="TextBox1" ForeColor="Red" CssClass="class1" />

下列 HTML 會在用戶端上針對先前的 Web 服務器控制項宣告呈現:The following HTML is rendered on the client for the previous Web server control declaration:

<input type=text class="class1" style="ForeColor:red">


在不支援 CSS 的瀏覽器上,設定 CssClass 屬性不會有任何作用。On browsers that do not support CSS, setting the CssClass property will have no effect.