System.Web.UI.WebControls Namespace
Provides data for the Command event.
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.
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>
CommandEventHandler Button.Command ImageButton.Command LinkButton.Command