Personas que lo han encontrado útil: 0 de 14 Valorar este tema

AttributeCollection.Add (Método)

Agrega un atributo al objeto AttributeCollection de un control de servidor.

Espacio de nombres: System.Web.UI
Ensamblado: System.Web (en system.web.dll)

public void Add (
	string key,
	string value
)
public void Add (
	String key, 
	String value
)
public function Add (
	key : String, 
	value : String
)
No aplicable.

Parámetros

key

Nombre del atributo.

value

Valor del atributo.

En el siguiente ejemplo se muestra cómo utilizar el método Add para agregar un atributo a la AttributeCollection de un control de servidor ASP.NET mediante programación.

<%@ 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.Attributes.Add("Multiple", "True");
    }
</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" 
            runat="server">
       <option>This</option>
       <option>That</option>
       <option>Other</option>
    </select>
    <br/><br/>

    <input type="submit" 
           id="submitbtn"
           value="modify attribute" 
           onserverclick="SubmitBtn_Click" 
           runat="server"/>
    </div>
 </form>
 </body>
 </html>

Windows 98, Windows 2000 Service Pack 4, Windows CE, Windows Millennium, Windows Mobile para Pocket PC, Windows Mobile para Smartphone, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter

Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.

.NET Framework

Compatible con: 3.0, 2.0, 1.1, 1.0
¿Le ha resultado útil?
(Caracteres restantes: 1500)