I have always added dynamic controls like so:
Label l = new Label();
l.Text = "Label 1";
this.Controls.Add(l);
on Page_Load. But if I try to add a Button dynamically, I get an error saying it has to be nested in a <form>.
So I checked the HTML source and saw that the items I add dynamically are added below the end </HTML> tag!
How can I add the controls so they're between the <form></form> tags?


Reply With Quote