System.Web.UI.WebControls Namespace CommandEventArgs Class
Retrieves the argument for the command.
Script |
[ Object variable = ] CommandEventArgs.CommandArgument |
variable |
A System.Object that contains the argument for the command. |
The property is read only with no default value.
The CommandArgument can contain any string set by the programmer. The CommandArgument property complements the CommandName property by allowing to provide any additional information for the command, to identify the CommandArgument in code and perform the approprate tasks.
The following example demonstrates how to access the CommandArgument property to determine supplemental information for 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>
CommandEventArgs Members Button.CommandArgument ImageButton.CommandArgument LinkButton.CommandArgument