Redigeeri

Jagamisviis:


CssStyleCollection.Remove Method

Definition

Removes a style item from the CssStyleCollection of a control.

Overloads

Remove(String)

Removes a style item from the CssStyleCollection of a control using the specified style key.

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.

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

Parameters

key
String

The string literal of the style item to remove.

Examples

The following example demonstrates how to use the Remove method to programmatically delete a CSS style from an HtmlSelect control.

<%@ 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>

See also

Applies to

Remove(HtmlTextWriterStyle)

Removes a style item from the CssStyleCollection collection of a control using the specified HtmlTextWriterStyle enumeration value.

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)

Parameters

key
HtmlTextWriterStyle

The HtmlTextWriterStyle enumeration value to remove.

See also

Applies to