Home » ASP.NET Basics » 06 - ASP.NET 2.0 Server Controls
6

Important Properties of some commonly used controls

Properties of server controls

Property

Use

Applicable to

ID

Gives a name to the control. This name is used to access the control in the program code.

Label, TextBox, Button, HyperLink, ListBox, DropDownList, CheckBox, RadioButton, Image.

BackColor

For providing a background color to the control.

Label, TextBox, Button, HyperLink, ListBox, DropDownList, CheckBox, RadioButton, Image.

BorderColor

For providing a color to the border of the control.

Label, TextBox, Button, HyperLink, CheckBox, RadioButton, Image.

BorderStyle

For setting the style of the border.

Label, TextBox, Button, HyperLink, CheckBox, RadioButton, Image.

BorderWidth

For setting the width of the border.

Label, TextBox, Button, HyperLink, CheckBox, RadioButton, Image.

Font

For setting the font properties like font size, font name, bold, italic, underline etc.

Label, TextBox, Button, HyperLink, ListBox, DropDownList, CheckBox, RadioButton.

ForeColor

For providing the color of the text within the control.

Label, TextBox, Button, HyperLink, ListBox, DropDownList, CheckBox, RadioButton, Image.

Text

For setting the text to be displayed on the control.

Label, TextBox, Button, HyperLink, CheckBox, RadioButton.

Width, Height

For setting the width and the height of the control on the page.

Label, TextBox, Button, HyperLink, ListBox, DropDownList, CheckBox, RadioButton, Image.

Visible

To indicate if the control will be displayed on the page or not.

Label, TextBox, Button, HyperLink, ListBox, DropDownList, CheckBox, RadioButton, Image.

Enabled

Whether the control is enabled on the page.

Label, TextBox, Button, HyperLink, ListBox, DropDownList, CheckBox, RadioButton.

MaxLength

To specify the maximum number of characters that can be entered in a TextBox. The default is 0 which means the property is not set.

TextBox

ReadOnly

Whether the text in the control can be changed or not.

TextBox

TextMode

To specify the behavior of the TextBox. `SingleLine' allows one line of text. `MultiLine' allows multiple lines of text. `Password' replaces the text entered with password character.

TextBox

NavigateUrl

To specify the URL for the hyperlink.

HyperLink

Checked

To specify the checked/un-checked state of the control.

CheckBox, RadioButton.

GroupName

To specify the group of the Radio button.

RadioButton

ImageUrl

The URL of the image to be shown.

Image

DataSourceID

The ID of the DataSource for the control.

ListBox, DropDownList

DataMember

To specify the table or view used for the control.

ListBox, DropDownList

Items

To specify the group of items for the control.

ListBox, DropDownList