Team LiB
Previous Section Next Section

ASP.NET Controls

HTML server controls are nothing more than regular HTML controls that run on the server. They always have the property runat="server" set on them. Web Server controls provide a richer functionality as well as following the XML syntax.

Tables 23-10 through 23-13 show the HTML server controls, Web server controls, common control properties, and the events that are common to every control.

Table 23-10: HTML Server Controls

Control

Description

HtmlForm

Equivalent to the <form> tag

HtmlInputText

Equivalent to the <input type="text"> tag

HtmlInputCheckBox

Equivalent to the <input type="checkbox"> tag

HtmlInputFile

Equivalent to the <input type="file"> tag

HtmlInputHidden

Equivalent to the <input type="hidden"> tag

HtmlInputImage

Equivalent to the <input type="image"> tag

HtmlInputRadioButton

Equivalent to the <input type="radio"> tag

HtmlInputButton

Equivalent to the <input type="button"> tag

HtmlButton

Equivalent to the <button> tag

HtmlSelect

Equivalent to the <select> tag

HtmlImage

Equivalent to the <image> tag

HtmlTextArea

Equivalent to the <textarea> tag

HtmlGenericControl

Equivalent to the <body>, <div>, <span>, or <font> tag

HtmlAnchor

Equivalent to the <a> or <anchor> tag

HtmlTable

Equivalent to the <table> tag

HtmlTableCell

Equivalent to the <td> tag

HtmlTableRow

Equivalent to the <tr> tag

Table 23-11: Web Server Controls

Control

Description

Example

TextBox

Input control

<asp:TextBox />

Label

Read-only control that is delivered as a <span> tag

<asp:Label />

Button

Control that causes an action

<asp:Button />

CheckBox

Input control that provides multiple selections

<asp:CheckBox />

RadioButton

Input control that provides a single selection given multiple options

<asp:RadioButton />

ImageButton

Button control that provides an image and is rendered as the <img> tag

<asp:ImageButton />

LinkButton

Action control that behaves like a hyperlink

<asp:LinkButton />

HyperLink

Control that behaves like a hyperlink that is rendered as an <a> or <anchor> tag

<asp:HyperLink />

Image

Control that displays an image and is rendered as an <img> tag

<asp:Image />

ListBox

Input control that is rendered as a <select> command

<asp:ListBox />

DropDownList

Control that creates a simple selection list and is rendered as the <select> command

<asp:DropDownList />

RadioButtonList

Creates a control that displays a series of radio button options

<asp:RadioButtonList />

DataList

List control that provides for good customization

<asp:DataList />

DataGrid

Control rendered as a table that allows for detailed customization

<asp:DataGrid />

Repeater

Allows for the display of multiple images

<asp:Repeater />

Table

Draws a table

<asp:Table />

TableCell

Creates a cell in a table

<asp:TableCell />

TableRow

Creates a row in a table

<asp:TableRow />

PlaceHolder

Container control that can be used to host other controls

<asp:PlaceHolder />

Literal

Displays static text

<asp:Literal />

Panel

Control used to contain other objects and is rendered as a <span> tag

<asp:Panel />

AdRotator

Displays advertisements

<asp:AdRotator />

Calendar

Displays a calendar

<asp:Calendar />

XML

XML transformation control

Presents XML data

Table 23-12: Common Control Properties

Property

Description

AccessKey

Assigns a shortcut key to a control

Attributes

Provides access to the attributes of a control

BackColor

Provides the background color of a control

BorderColor

Provides the border color of a control

BorderWidth

Changes the border width of a control

BorderStyle

Changes the border style of a control

CssClass

Sets the CSS class name

Style

Sets the CSS style

Enabled

Enables or disables the control

Font

Sets the font of the control

ForeColor

Sets the foreground color of the control

Height

Sets the height of the control

TabIndex

Sets the tab index of the control

Tool

Sets the tooltip help text

Width

Sets the width of the control

Table 23-13: Common Control Events

Event

Description

DataBinding

Raised when the DataBind method is called

Disposed

Occurs when the control is released from memory

Init

Occurs when the control is first initialized

Load

Occurs when the control is loaded into the page object

PreRender

Occurs just prior to when the control's Render method is called

Unload

Occurs when the control is unloaded from memory


Team LiB
Previous Section Next Section