The HtmlSelect class defines the methods, properties, and events for the HtmlSelect control. This class allows programmatic access to the HTML <select> element on the server.
Object
Control
HtmlControl
HtmlContainerControl
HtmlSelect
[Visual Basic] Public Class HtmlSelect Inherits HtmlContainerControl Implements IPostBackDataHandler [C#] public class HtmlSelect : HtmlContainerControl, IPostBackDataHandler [C++] public __gc class HtmlSelect : public HtmlContainerControl, IPostBackDataHandler [JScript] public class HtmlSelect extends HtmlContainerControl, IPostBackDataHandler
[To be supplied.]
Namespace: System.Web.UI.HtmlControls
Assembly: System.Web.dll
The following example demonstrates how option entries can be dynamically added to an HtmlSelect control.
[Visual Basic]
<html> <script language="VB" runat=server> Overrides Sub_Load() If (IsFirstLoad = true) Then MyList.Items.Add "Basketball" MyList.Items.Add "Football" MyList.Items.Add "Soccer" End If End Sub Sub SubmitBtn_Click (ByVal Source As Object, ByVal E as EventArgs) Message.InnerHtml = "Favorite sport: "& MyList.Value End Sub </script> <body> <form method=post runat=server> Select your favorite sport: <select id="MyList" size=1 runat=server> <option>Baseball</option> <option>Ping Pong</option> </select> <input type=button value="Enter" OnServerClick="SubmitBtn_Click" runat=server> <h1><span id="Message" runat=server></span></h1> </form> </body> </html>