ImageButton.CommandArgument (Propiedad)
Ensamblado: System.Web (en system.web.dll)
[ThemeableAttribute(false)] [BindableAttribute(true)] public string CommandArgument { get; set; }
/** @property */ public final String get_CommandArgument () /** @property */ public final void set_CommandArgument (String value)
public final function get CommandArgument () : String public final function set CommandArgument (value : String)
Valor de propiedad
Argumento opcional que complementa la propiedad CommandName.A veces, varios controles ImageButton están relacionados y comparten el mismo valor para la propiedad CommandName, por ejemplo, Sort. Utilice esta propiedad para complementar la propiedad CommandName con información adicional sobre el comando que se va a ejecutar, como Ascending. Los valores de las propiedades CommandName y CommandArgument se utilizan normalmente en el controlador de eventos OnCommand para determinar la acción que se ha de realizar al hacer clic en el control ImageButton.
Esta propiedad no se puede establecer por temas o temas de hoja de estilos. Para obtener más información, vea ThemeableAttribute y Información general sobre temas y máscaras de ASP.NET.
En el siguiente ejemplo se muestra cómo usar la propiedad CommandArgument para asociar un argumento de comando a un control ImageButton.
Nota: |
|---|
| El ejemplo de código siguiente utiliza un modelo de código de un solo archivo y puede no funcionar correctamente si se copia directamente en un archivo con el código subyacente. Se debe copiar este ejemplo de código en un archivo de texto vacío con la extensión .aspx. Para obtener más información sobre el modelo de código de los formularios Web Forms, vea Modelo de código de las páginas Web ASP.NET. |
<%@ Page Language="C#" AutoEventWireup="True" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>ImageButton CommandName Sample</title> <script language="C#" runat="server"> void ImageButton_Command(object sender, CommandEventArgs e) { if (e.CommandName == "Sort" && e.CommandArgument == "Ascending") Label1.Text = "You clicked the Sort Ascending Button"; else Label1.Text = "You clicked the Sort Descending Button"; } </script> </head> <body> <form id="form1" runat="server"> <h3>ImageButton CommandName Sample</h3> Click an image.<br /><br /> <asp:ImageButton id="imagebutton1" runat="server" AlternateText="Sort Ascending" ImageUrl="images/pict.jpg" OnCommand="ImageButton_Command" CommandName="Sort" CommandArgument="Ascending"/> <asp:ImageButton id="imagebutton2" runat="server" AlternateText="Sort Descending" ImageUrl="image/pict2.jpg" OnCommand="ImageButton_Command" CommandName="Sort" CommandArgument="Descending"/> <br /><br /> <asp:label id="Label1" runat="server"/> </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.
Nota: