CssStyleCollection.Remove 方法

定义

从控件的 CssStyleCollection 中移除样式项。

重载

Remove(String)

使用指定的样式键从控件的 CssStyleCollection 中移除样式项。

Remove(HtmlTextWriterStyle)

使用指定的 CssStyleCollection 枚举值从控件的 HtmlTextWriterStyle 集合移除样式项。

Remove(String)

使用指定的样式键从控件的 CssStyleCollection 中移除样式项。

public:
 void Remove(System::String ^ key);
public void Remove (string key);
member this.Remove : string -> unit
Public Sub Remove (key As String)

参数

key
String

要移除的样式项的字符串。

示例

以下示例演示如何使用 Remove 方法以编程方式从 HtmlSelect 控件中删除 CSS 样式。

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  protected void SubmitBtn_Click(object sender, EventArgs e)
  {
    FirstSelect.Style.Remove("font");
  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>CssStyleCollection Remove Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    Click the submit button to clear the font formatting.
    <br />
    <select id="FirstSelect" 
            style="font: 14pt Arial; background-color:Yellow; color:Blue;"
            runat="server">
        <option >option 1</option>
        <option >option 2</option>
        <option >option 3</option>
    </select> 
    <input id="SubmitBtn" 
           value="Submit" 
           type="submit" 
           onserverclick="SubmitBtn_Click"
           runat="server" /><br />
    </div>
    </form>
</body></html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  Protected Sub SubmitBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)

    FirstSelect.Style.Remove("font")
    
  End Sub
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>CssStyleCollection Remove Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    Click the submit button to clear the font formatting.
    <br />
    <select id="FirstSelect" 
            style="font: 14pt Arial; background-color:Yellow; color:Blue;"
            runat="server">
        <option >option 1</option>
        <option >option 2</option>
        <option >option 3</option>
    </select> 
    <input id="SubmitBtn" 
           value="Submit" 
           type="submit" 
           onserverclick="SubmitBtn_Click"
           runat="server" /><br />
    </div>
    </form>
</body></html>

另请参阅

适用于

Remove(HtmlTextWriterStyle)

使用指定的 CssStyleCollection 枚举值从控件的 HtmlTextWriterStyle 集合移除样式项。

public:
 void Remove(System::Web::UI::HtmlTextWriterStyle key);
public void Remove (System.Web.UI.HtmlTextWriterStyle key);
member this.Remove : System.Web.UI.HtmlTextWriterStyle -> unit
Public Sub Remove (key As HtmlTextWriterStyle)

参数

key
HtmlTextWriterStyle

要移除的 HtmlTextWriterStyle 枚举值。

另请参阅

适用于