This documentation is archived and is not being maintained.
HtmlSelect Constructor
.NET Framework 1.1
Initializes a new instance of the HtmlSelect class.
[Visual Basic] Public Sub New() [C#] public HtmlSelect(); [C++] public: HtmlSelect(); [JScript] public function HtmlSelect();
Remarks
Use this constructor to create and initialize a new instance of the HtmlSelect class.
The following table shows initial property values for an instance of HtmlSelect.
| Property | Initial Value |
|---|---|
| TagName | The "select" literal string. |
Example
[Visual Basic] <%@ Page Language="VB" AutoEventWireup="True" %> <html> <script runat="server" > Sub Page_Load(sender As Object, e As EventArgs) ' Create an HtmlSelect control. Dim selectlist As HtmlSelect = New HtmlSelect() ' Populate the HtmlSelect control. Dim i As Integer For i=0 to 4 Dim item As ListItem = _ New ListItem("Item " + i.ToString(), i.ToString()) selectlist.Items.Add(item) Next i ' Add the control to the Controls collection of the ' PlaceHolder control. Place.Controls.Clear() Place.Controls.Add(selectlist) End Sub </script> <body> <form runat="server"> <h3> HtmlSelect Constructor Example </h3> <asp:PlaceHolder id="Place" runat="server"/> </form> </body> </html> [C#] <%@ Page Language="C#" AutoEventWireup="True" %> <html> <script runat="server" > void Page_Load(Object sender, EventArgs e) { // Create an HtmlSelect control. HtmlSelect selectlist = new HtmlSelect(); // Populate the HtmlSelect control. for(int i=0; i<5; i++) { ListItem item = new ListItem("Item " + i.ToString(), i.ToString()); selectlist.Items.Add(item); } // Add the control to the Controls collection of the // PlaceHolder control. Place.Controls.Clear(); Place.Controls.Add(selectlist); } </script> <body> <form runat="server"> <h3> HtmlSelect Constructor Example </h3> <asp:PlaceHolder id="Place" runat="server"/> </form> </body> </html>
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also
HtmlSelect Class | HtmlSelect Members | System.Web.UI.HtmlControls Namespace
Show: