ASP.NET HtmlSelect Control
HTML Server Controls
Definition and Usage
The HtmlSelect control is used to control the element is used to create a drop-down list.
property
| property | Description |
|---|---|
| Attributes | Returns all attribute name and value pairs of the 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 that provides the value of each option in this drop-down list. |
| Disabled | A Boolean value that indicates whether the control is disabled. The default is false. |
| id | The unique id of the control. |
| InnerHtml | Sets or returns the content between the opening and closing tags of this HTML element. Special characters are not automatically converted to HTML entities. |
| InnerText | Sets or returns all text between the opening and closing tags of this 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 is changed. |
| runat | Specifies that this 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 this control. |
| TagName | Returns the tag name of the element. |
| Value | The value of the currently selected item. |
| Visible | A Boolean value that indicates whether the control is visible. |
Example
HTMLSelect
In this example, we declare an HtmlImage control and an HTMLSelect control in the .aspx file (remember to nest the controls inside the 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 Controls