ankitweblogic logo
W e b t u t o r i a l s

ASP.NET Tutorial


ASP.NET Introduction

ASP.NET Web Forms

Standard Controls

Label Control

TextBox Control

Image Control

Button Controls

Redirecting User

Using HyperLinks

RadioButton Control


CheckBox Control

CheckBoxList Control


ListBox Control

ImageMap Control

Master Page

View State

Event-Driven Programming


ASP.NET Page Structure

Visibility of Controls

Formatting Controls

Applying CSS

Dynamic CSS

Using Style Class

Themes and Skins

Panel Control

PlaceHolder Control

AdRotator Control

Calendar Control

Validation Controls

Page Navigation

User Control

Separating Code-Presentation

Overview of ADO.NET

Data Binding

DataBinding List Control

Button Control

There are 3 types of button controls in ASP.NET. They are:
• Button: This is the standard HTML Submit button.
• LinkButton: This button looks like a hyperlink on the client. It requires client-side JavaScript support.
• ImageButton: This button displays an image on the client.

The properties, methods, and events of Button control are:

Property Description
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.
Method Description
OnClick Raises Click event.
OnCommand Raises Command event.
Event Description
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.