System.Web.UI.WebControls.ImageButton.OnCommand Method

Raises the ImageButton.Command event and allows you to handle the ImageButton.Command event directly.

Syntax

protected virtual void OnCommand (CommandEventArgs e)

Parameters

e
A System.Web.UI.WebControls.CommandEventArgs that contains the event data.

Remarks

The ImageButton.Command event is raised when the System.Web.UI.WebControls.ImageButton control is clicked. The ImageButton.OnCommand(CommandEventArgs) event handler is used to make the System.Web.UI.WebControls.ImageButton control behave like a Command button. A command name can be associated with the control by using the ImageButton.CommandName property. This allows multiple System.Web.UI.WebControls.ImageButton controls to be placed on the Web page. The value in this property can then be programmatically identified in the ImageButton.OnCommand(CommandEventArgs) event handler to determine the appropriate action to perform when each System.Web.UI.WebControls.ImageButton control is clicked. The ImageButton.CommandArgument property can also be used to pass additional information about the command, such as specifying ascending order.

Note:

The ImageButton.Command event is raised through the control hierarchy in the form of the BubbleEvent.

Raising an event invokes the event handler through a delegate. For more information, see How to: Consume Events in a Web Forms Application.

The ImageButton.OnCommand(CommandEventArgs) method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0