asp.net.ph

ImageButton.CommandArgument Property

System.Web.UI.WebControls Namespace   ImageButton Class


Sets or retrieves an optional parameter passed to the Command event along with the associated CommandName.

Syntax


Inline <asp:imagebutton commandargument = strValue ... >
Script ImageButton.CommandArgument = strValue

Property Value


strValue String specifying an optional parameter passed to the Command event along with the associated CommandName.

The property is read/write with no default value.

Remarks

Use the CommandArgument property to specify an optional parameter that complements the CommandName property.

NOTE: While you can set the CommandArgument property by itself, it is normally only used when the CommandName property is also set.

The CommandArgument property complements the CommandName property by allowing you to provide additional information about the action to perform when the ImageButton is clicked. For example, a CommandName property set to Sort may have a CommandArgument property set to Ascending, so the code can handle the command appropriately.

Example

The following example demonstrates how to set the CommandArgument property at design time, to create an ImageButton control that sorts a list in ascending order.

<form runat = "server">

   <asp:imagebutton id = "myImageButton" runat = "server"
      imageurl = "sort.jpg"
      commandname = "Sort"
      commandargument = "Ascending"
      onCommand = "getCommandArgs" />

</form>

The below example demontrates an Command event handler that, in this case, simply determines the event arguments passed to the handler when an ImageButton is clicked.

void getCommandArgs ( Object src, CommandEventArgs e ) {
   // insert code to sort in ascending order here.
   msg.Text = "You clicked the " + e.CommandName +
      " - " + e.CommandArgument + " imagebutton.";
}
  C# VB

See Also

ImageButton Members   Command Event Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph