System.Web.UI.WebControls Namespace CommandEventArgs Class
Retrieves the name of the command.
Script |
[ String variable = ] CommandEventArgs.CommandName |
variable |
String specifying the name of the command to perform. |
The property is read only with no default value.
Use the CommandName property to determine the command to perform. The CommandName can contain any string set by the programmer. The programmer can then identify the command name in code and perform the appropriate tasks.
The following example demonstrates how to access the CommandName property to determine the command to perform.
<script language = "C#" runat = "server">
void myCommandEventHandler ( Object src, CommandEventArgs e ) {
if ( e.CommandName == "Sort" )
// ... insert code to sort.
else
// ... insert code to perform alternative.
}
</script>
CommandEventArgs Members Button.CommandName ImageButton.CommandName LinkButton.CommandName