Introduction to the Command ControlĀ 

The Command control provides ASP.NET mobile Web pages with the ability to post user input to the server.

Remarks

The appearance of the Command control varies depending on its property settings and the type of device in which it is being rendered. It can appear as a button, image, link, or softkey. A softkey is a programmable button available on many cell phones.

ASP.NET Command Control

A Command control must be placed within a Form or Panel control, or inside a control's template on a mobile Web page. You can also drag it onto a mobile user control page. Use the Properties window to specify the value of the Format property, which determines the preferred visual appearance of the control. Set the Text property with the string that the Command control displays when it is rendered. If an application runs on a device that supports softkeys, the Command control displays the text contained in the SoftkeyLabel property as the label for the softkey.

The Command control can display an image on devices that support images. Specify the URL for the image's location in the ImageUrl property.

Each Command control must have a name. Set its name with the CommandName property. When the user selects a Command control, it generates a Click event and invokes the OnClick method. In addition, it generates an ItemCommand event. The ItemCommand event is propagated to its parent controls. The Click event is not. Your application can provide handlers for these events.

Additionally, you can define argument values when you design your application. Do this by setting the CommandArgument property. When the application raises an ItemCommand event, it passes the value in the CommandArgument member of the CommandEventArgs parameter to the handler.

By default, the value of a Command control's CausesValidation property is true. This causes the server to perform validation on all other controls in the same form. To disable this behavior, set CausesValidation to false.

Apply device filters to enable the use of property override values. By overriding property values, you can customize the appearance of Command controls for specific types of devices.

To configure the appearance of the Command control dynamically, your application can use data binding.

See Also

Tasks

How to: Add and Configure a Command Control

Reference

Command

Concepts

Overriding Properties
Introduction to the Form Control
Introduction to the Panel Control

Other Resources

Using Device Filters