There are 3 types of button controls in ASP.NET. They are:
• Button: This is the standard HTML Submit button.
• ImageButton: This button displays an image on the client.
The properties, methods, and events of Button control are:
|Text||Gets or sets the text displayed on the button or the link in case of a LinkButton. Not available for ImageButton.|
|CommandName||Passed to Command event when button is clicked.|
|CommandArgument||Passed to Command event when button is clicked.|
|CausesValidation||By default, True. If False, the form submitted by the button is not validated.|
|AlternativeText||Gets or sets the text displayed on the ImageButton when the browser does not support images.|
|ImageAlign||Aligns image on ImageButton. Can take the values: AbsBottom, AbsMiddle, Baseline, Bottom, Left, Middle, NotSet, Right, TextTop, Top|
|ImageURL||Specifies URL of image to be used for ImageButton.|
|OnClick||Raises Click event.|
|OnCommand||Raises Command event.|
|Click||Raised when button is clicked and the form is submitted to the server.|
|Command||This event is also raised when button is clicked. Passes additional information through CommandName and CommandArgument properties.|
The Command event is also raised when a button is clicked. The difference between the two events is that you can pass additional information as values of the CommandName and CommandArgument properties.
Suppose you have two buttons on a form, Credit and Debit. You wish to pass the amount to be credited when the Credit button is clicked and the amount to be debited when the Debit button is clicked. Example shows you how to handle the Command event.