Este artigo foi traduzido por máquina. Coloque o ponteiro do mouse sobre as frases do artigo para ver o texto original. Mais informações.
Tradução
Original
Este tópico ainda não foi avaliado como - Avalie este tópico

CommandEventArgs Classe

Provides data for the Command event.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (em System.Web. dll)

[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class CommandEventArgs : EventArgs

The Command event is raised when a Button or ImageButton control is clicked.

The CommandEventArgs object contains data about the Command event that can be accessed in the event handler.Using the properties available in the CommandEventArgs class, you can determine the name of the command to perform, such as Sort, in addition to an optional argument that supplements the command, such as Ascending.

For a list of initial property values for an instance of CommandEventArgs, see the CommandEventArgs constructor.

For more information about handling events, see Consumindo Eventos.

The following example demonstrates how to access the properties in CommandEventArgs to determine the command to perform.This example specifies the event handler declaratively, using the OnClick property of the Button control.

<%@ Page Language= AutoEventWireup= %>

<!DOCTYPE html PUBLIC "-
    "http:
<html xmlns="http:
<head runat=>
    <title>Button CommandName Example</title>
<script runat=>

       CommandBtn_Click(Object sender, CommandEventArgs e) 
      {

         (e.CommandName)
         {

             :

               
               Sort_List((String)e.CommandArgument);
               ;

             :

               
               Message.Text = ;

               
               ((String)e.CommandArgument == )
               {
                  
                  Message.Text += ;
               }
               
               {
                  
                  Message.Text += ;
               }                
               ;

            :

               
               Message.Text = ;
               ; 

         }

      }

       Sort_List(string commandArgument)
      {

         (commandArgument)
         {

             :

               
               Message.Text = ;
               ;

             :

               
               Message.Text = ;
               ;

            :

               
               Message.Text = ;
               ;

         }

      }

   </script>

</head>

<body>

   <form id= runat=>

      <h3>Button CommandName Example</h3>

      Click  one of the command buttons.

      <br /><br />

      <asp:Button id=
           Text=
           CommandName=
           CommandArgument=
           OnCommand= 
           runat=/>

      &nbsp;

      <asp:Button id=
           Text=
           CommandName=
           CommandArgument=
           OnCommand= 
           runat=/>

      <br /><br />

      <asp:Button id=
           Text=
           CommandName=
           OnCommand= 
           runat=/>

      &nbsp;

      <asp:Button id=
           Text=
           CommandName=
           CommandArgument=
           OnCommand= 
           runat=/>

      &nbsp;

      <asp:Button id=
           Text=
           CommandName=
           CommandArgument=
           OnCommand= 
           runat=/>

      <br /><br />

      <asp:Label id= runat=/>

   </form>

</body>
</html>



The following code example demonstrates how to specify the event handler and programmatically add it to the event in the Page_Load method.

<%@ Page Language= AutoEventWireup= %>

<!DOCTYPE html PUBLIC "-
    "http:
<html xmlns="http:
<head runat=>
    <title>Button CommandName Example</title>
<script runat=>

       CommandBtn_Click(Object sender, CommandEventArgs e) 
      {

         (e.CommandName)
         {

             :

               
               Sort_List((String)e.CommandArgument);
               ;

             :

               
               Message.Text = ;

               
               ((String)e.CommandArgument == )
               {
                  
                  Message.Text += ;
               }
               
               {
                  
                  Message.Text += ;
               }                
               ;

            :

               
               Message.Text = ;
               ; 

         }

      }

       Sort_List(string commandArgument)
      {

         (commandArgument)
         {

             :

               
               Message.Text = ;
               ;

             :

               
               Message.Text = ;
               ;

            :

               
               Message.Text = ;
               ;

         }

      }

       Page_Load(Object sender, EventArgs e)
      {

         
         
         Button1.Command +=  CommandEventHandler(.CommandBtn_Click);
         Button2.Command +=  CommandEventHandler(.CommandBtn_Click);
         Button3.Command +=  CommandEventHandler(.CommandBtn_Click);
         Button4.Command +=  CommandEventHandler(.CommandBtn_Click);
         Button5.Command +=  CommandEventHandler(.CommandBtn_Click);

      }

   </script>

</head>

<body>

   <form id= runat=>

      <h3>Button CommandName Example</h3>

      Click one of the command buttons.

      <br /><br />

      <asp:Button id=
           Text=
           CommandName=
           CommandArgument=
           runat=/>

      &nbsp;

      <asp:Button id=
           Text=
           CommandName=
           CommandArgument=
           runat=/>

      <br /><br />

      <asp:Button id=
           Text=
           CommandName=
           runat=/>

      &nbsp;

      <asp:Button id=
           Text=
           CommandName=
           CommandArgument=
           runat=/>

      &nbsp;

      <asp:Button id=
           Text=
           CommandName=
           CommandArgument=
           runat=/>

      <br /><br />

      <asp:Label id= runat=/>

   </form>

</body>
</html>



Quaisquer membros públicos estático (compartilhados na Visual Basic) desse tipo são Thread seguro. Não há garantia de que qualquer membro de instância seja isento de segmentos.
Isso foi útil para você?
(1500 caracteres restantes)

Contribuições da comunidade

ADICIONAR
© 2013 Microsoft. Todos os direitos reservados.