Freigeben über


AttributeCollection.Clear-Methode

Entfernt alle Attribute aus dem AttributeCollection-Objekt eines Serversteuerelements.

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

Syntax

'Declaration
Public Sub Clear
'Usage
Dim instance As AttributeCollection

instance.Clear
public void Clear ()
public:
void Clear ()
public void Clear ()
public function Clear ()

Beispiel

Im folgenden Beispiel wird veranschaulicht, wie Sie programmgesteuert alle Attribute aus dem AttributeCollection-Objekt eines HTML-Serversteuerelements entfernen können.

<%@ 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 ClearAttribute_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        FirstSelect.Attributes.Clear()
    End Sub
    
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>AttributeCollection Example</title>
</head>

 <body>
    <form id="form1" runat="server">
    <div>
    Make a selection:
    <select id="FirstSelect"
            style="font:16pt verdana;background-color:yellow;color:black;" 
            runat="server">
       <option>This</option>
       <option>That</option>
       <option>Other</option>
    </select>
    <br/><br/>

    <input type="submit" 
           id="ClearAttributes"
           value="Clear All Attributes" 
           onserverclick="ClearAttribute_Click" 
           runat="server"/>
    </div>
 </form>
 </body>
 </html>
<%@ 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 ClearAttribute_Click(object sender, EventArgs e)
    {
        FirstSelect.Attributes.Clear();
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>AttributeCollection Example</title>
</head>

 <body>
    <form id="form1" runat="server">
    <div>
    Make a selection:
    <select id="FirstSelect"
            style="font:16pt verdana;background-color:yellow;color:black;" 
            runat="server">
       <option>This</option>
       <option>That</option>
       <option>Other</option>
    </select>
    <br/><br/>

    <input type="submit" 
           id="ClearAttributes"
           value="Clear All Attributes" 
           onserverclick="ClearAttribute_Click" 
           runat="server"/>
    </div>
 </form>
 </body>
 </html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script language="jscript" runat="server">

    function ClearAttribute_Click(Src, e : EventArgs){
        FirstSelect.Attributes.Clear();
    }
    
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>AttributeCollection Example</title>
</head>

 <body>
    <form id="form1" runat="server">
    <div>
    Make a selection:
    <select id="FirstSelect"
            style="font:16pt verdana;background-color:yellow;color:black;" 
            runat="server">
       <option>This</option>
       <option>That</option>
       <option>Other</option>
    </select>
    <br/><br/>

    <input type="submit" 
           id="ClearAttributes"
           value="Clear All Attributes" 
           onserverclick="ClearAttribute_Click" 
           runat="server"/>
    </div>
 </form>
 </body>
 </html>

Plattformen

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

AttributeCollection-Klasse
AttributeCollection-Member
System.Web.UI-Namespace
Attributes
Attributes