Share via


CommandArgument Property

Sets or returns the argument associated with the command in the ItemCommand event. The default value is an empty string ("").

public string CommandArgument {
   get,
   set
}

Inheritance

The following is a list of the mobile control classes that inherit the CommandArgument property from the Web Forms CommandEventArgs Class class.

ListCommandEventArgs Class ObjectListCommandEventArgs Class

Example

The following example demonstrates how to use the CommandArgument property to display the specified command argument of 70.

Sub cmd_OnItemCommand(sender As Object, e As CommandEventArgs)

   Label1.Text = "Today's quote of " + e.CommandName + " is " + e.CommandArgument
   Label2.Text = "Yestrday's quote of " + e.CommandName + " was " +(Convert.ToInt32(e.CommandArgument) - 5).ToString()

End Sub 

<mobile:form id="myForm" runat=server Alignment=Center >
   <mobile:command id="CmdMSFT" onItemCommand = "cmd_OnItemCommand" 
      CommandArgument="70" CommandName="MSFT" runat="server" 
      Text="MICROSOFT" />
</mobile:form>
[C#]
void cmd_OnItemCommand(object sender, CommandEventArgs e)
{
   Label1.Text = "Today's quote of " + e.CommandName + 
     " is " + e.CommandArgument;"'""" 
}

<mobile:form id="myForm" runat=server Alignment=Center >
   <mobile:command id="CmdMSFT" onItemCommand = "cmd_OnItemCommand" 
      CommandArgument="70" CommandName="MSFT" runat="server" 
      Text="MICROSOFT" />
</mobile:form> 

See Also

Applies to: Command Class