This documentation is archived and is not being maintained.

CssStyleCollection.Clear Method

Removes all style items from the CssStyleCollection object.

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

public void Clear()

The following example demonstrates how to use the Clear method to programmatically delete all CSS styles from an HtmlSelect control.

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

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

<script runat="server">

  protected void SubmitBtn_Click(object sender, EventArgs e)


<html xmlns="" >
<head runat="server">
    <title>CssStyleCollection Clear Example</title>
    <form id="form1" runat="server">
    Click the submit button to clear the formatting.
    <br />
    <select id="FirstSelect" 
            style="font: 12pt Arial; background-color:Yellow; color:Blue;"
        <option >option 1</option>
        <option >option 2</option>
        <option >option 3</option>
    <input id="SubmitBtn" 
           runat="server" /><br />

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

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.