ASP.NET HtmlSelect Control


HTML Server ControlsHTML Server Controls

Definition and Usage

The HtmlSelect control is used to control the <select> element. In HTML, the <select> element is used to create a drop-down list.


Attributes

Attributes Description
Attributes Returns all attribute name and value pairs of this element.
DataMember The name of the data table to use.
DataSource The data source to use.
DataTextField The field in the data source to display in this drop-down list.
DataValueField Specifies the field in the data source for the value of each selectable item in this drop-down list.
Disabled A Boolean value indicating whether the control is disabled. The default is false.
id The unique id of the control.
InnerHtml Sets or returns the content between the start and end tags of the HTML element. Special characters are not automatically converted to HTML entities.
InnerText Sets or returns all text between the start and end tags of the HTML element. Special characters are automatically converted to HTML entities.
Items The list of items in the drop-down list.
Multiple Whether multiple items can be selected at the same time.
OnServerChange The name of the function executed when the selected item changes.
runat Specifies that the control is a server control. Must be set to "server".
SelectedIndex The index number of the currently selected item.
Size The number of visible items in the drop-down list.
Style Sets or returns the CSS properties applied to the control.
TagName Returns the tag name of the element.
Value The value of the currently selected item.
Visible A Boolean value indicating whether the control is visible.


Examples

HTMLSelect
In this example, we declare an HtmlImage control and an HtmlSelect control in the .aspx file (remember to nest the controls inside an HtmlForm control). Then we modify the src attribute of the HtmlImage control based on the user's selection. The value selected in the HtmlSelect control determines which image is displayed.


HTML Server ControlsHTML Server Controls Other Extensions