HI there,
I'm trying to create Drop Down Lists dynamically.
Two thing before we start:
1. Im working on a ContentPanel that is inside a master page
2. I cant add anything to the .aspx directly, so all the code must be inside the .aspx.cs
This is my code:
public void GenerateDDL(Page page){
DropDownList element;
element = new DropDownList();
element.ID = "uxDropDownList";
page.Controls.Add(element);
}
So far it worked just fine when it came to adding Labels, Images and Hyperlinks dynamically; but for some reason, when I try to add the DropDownList using the very same process I get the following error:
----->"Control 'uxDropDownList' of type 'DropDownList' must be placed inside a form tag with runat=server."
Any ideas how to make this work? Or how to add the server tag dynamically?