CommandEventArgs Class


Provides data for the Command event.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public ref class CommandEventArgs : EventArgs


Initializes a new instance of the CommandEventArgs class with another CommandEventArgs object.

System_CAPS_pubmethodCommandEventArgs(String^, Object^)

Initializes a new instance of the CommandEventArgs class with the specified command name and argument.


Gets the argument for the command.


Gets the name of the command.


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)


Serves as the default hash function. (Inherited from Object.)


Gets the Type of the current instance.(Inherited from Object.)


Creates a shallow copy of the current Object.(Inherited from Object.)


Returns a string that represents the current object.(Inherited from Object.)

The Command event is raised when a Button or ImageButton control is clicked.

The CommandEventArgs object contains data about the Command event that can be accessed in the event handler. Using the properties available in the CommandEventArgs class, you can determine the name of the command to perform, such as Sort, in addition to an optional argument that supplements the command, such as Ascending.

For a list of initial property values for an instance of CommandEventArgs, see the CommandEventArgs constructor.

For more information about handling events, see NIB: Consuming Events.

The following example demonstrates how to access the properties in CommandEventArgs to determine the command to perform. This example specifies the event handler declaratively, using the OnClick property of the Button control.

No code example is currently available or this language may not be supported.

The following code example demonstrates how to specify the event handler and programmatically add it to the event in the Page_Load method.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top