I am trying to add a dropdownlist to a web form and failing
I have the following code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim x As New DropDownList()
With x
.Font.Bold = True
.Style.Add("position", "absolute")
.Style.Add("left", "420px")
.Style.Add("top", "50px")
.Style.Add("Width", "250px")
End With
Controls.Add(x)
End Sub
I recieve the following message:
Control '_ctl0' of type 'DropDownList' must be placed inside a form tag with runat=server.
If I change:
Dim x As New DropDownList()
To
Dim x As New Label() it runs
Any thoughts?
Thanks!
I have the following code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim x As New DropDownList()
With x
.Font.Bold = True
.Style.Add("position", "absolute")
.Style.Add("left", "420px")
.Style.Add("top", "50px")
.Style.Add("Width", "250px")
End With
Controls.Add(x)
End Sub
I recieve the following message:
Control '_ctl0' of type 'DropDownList' must be placed inside a form tag with runat=server.
If I change:
Dim x As New DropDownList()
To
Dim x As New Label() it runs
Any thoughts?
Thanks!