asp.net.ph

CommandEventArgs Class

System.Web.UI.WebControls Namespace


Provides data for the Command event.

CommandEventArgs Class Members

Collapse   Constructors

Visibility Constructor Parameters
public CommandEventArgs ( CommandEventArgs e )
public CommandEventArgs ( String commandName , Object argument )

Collapse   Properties

Visibility Name Value Type Accessibility
public CommandArgument Object [ Get ]
public CommandName String [ Get ]

Remarks

A Command event is raised whenever any command-type button control on a Web Forms page is clicked. Command-type buttons include any instance of a Button, ImageButton, or LinkButton class.

Information associated with the command event is summed up in a CommandEventArgs object, that is made accessible to the designated event handler.

This information includes the name of the command to perform, such as Sort, in addition to an optional argument that describes 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 Web Forms Events Model.

Example

The following example demonstrates how to access the properties of the CommandEventArgs object to determine the command to perform.

<script language = "C#" runat=server>
   void myCommandEventHandler ( Object src, CommandEventArgs e ) {
      if ( e.CommandName == "Sort" && e.CommandArgument == "Ascending" )
         // ... insert code to sort in ascending order.
      else
         // ... insert code to perform alternative.
   }
</script>

<form runat = "server">

   <asp:button id = "myButton" runat = "server"
      text = "Sort List"
      commandname = "Sort"
      commandargument = "Ascending"
      onCommand = "myCommandEventHandler" />

</form>
See Also

CommandEventHandler   Button.Command   ImageButton.Command   LinkButton.Command Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph