Command.CommandArgument Property
.NET Framework (current version)
Sets or returns the argument associated with the command in the ItemCommand event. The default value is an empty string (""). This API is obsolete. For information about how to develop ASP.NET mobile applications, see the www.asp.net/mobile Web site.
Assembly: System.Web.Mobile (in System.Web.Mobile.dll)
The following code example demonstrates how to the use the CommandArgument property to display a value.
Note |
|---|
The following code example uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code example must be copied into an empty text file that has an .aspx extension. For more information, see ASP.NET Web Forms Page Code Model. |
<%@ Page Language="C#" Inherits="System.Web.UI.MobileControls.MobilePage" %> <%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %> <script runat="server"> void cmd_OnItemCommand(object sender, CommandEventArgs e) { // Create variables for data string txt1 = "Today's quote of {0} is {1}"; string txt2 = "Yesterday's quote of {0} was {1}"; int val = (Convert.ToInt32(e.CommandArgument) - 5); // Set the text values of the labels message1.Text = String.Format(txt1, e.CommandName, e.CommandArgument); message2.Text = String.Format(txt2, e.CommandName, val); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <body> <mobile:form id="form1" runat="server"> <p> <mobile:label id="message1" runat="server"> Click the button for quotes </mobile:label> <mobile:label id="message2" runat="server" /> </p> <mobile:command id="CmdA" Format="Link" onItemCommand ="cmd_OnItemCommand" CommandArgument="70" CommandName="ca" runat="server" Text="Company A" /> <mobile:command id="CmdB" Format="Link" onItemCommand ="cmd_OnItemCommand" CommandArgument="25" CommandName="cb" runat="server" Text="Company B" /> <mobile:command id="CmdC" Format="Button" OnItemCommand ="cmd_OnItemCommand" CommandArgument="110" CommandName="cc" runat="server" Text= "Company C" /> </mobile:form> </body> </html>
.NET Framework
Available since 1.1
Available since 1.1
Command Class
System.Web.UI.MobileControls Namespace
Introduction to the Command Control
Show:
