I just come to a page where I need to add a series of checkboxes programmatically from a database and although I've figured out how to add an ASP.NET control dynamically and place it within a panel, it seems a real drag to have to add literal controls to add all the surrounding HTML.
I add controls like this
Dim myInput As TextBox = New TextBox()
myInput.Text = "Label1 "
myInput.ID = "Label1"
FormPanel.Controls.Add(myInput)
A) Is there a better way to add controls dynamically and possition the corresponding HTML around them?
B) If I don't need the functionality of an asp server control is it a sin to just write out the HTML for an old sytle HTML Input element enclosed in the other HTML needed. Also will an ASP.Net server control still function to post back the form?
C) As I will need to loop through the contents of the form when posted back does either of the above two provide an major problems?
I can see that this is an area worth investing some time in to get right, so any help would be appreciated.
I add controls like this
Dim myInput As TextBox = New TextBox()
myInput.Text = "Label1 "
myInput.ID = "Label1"
FormPanel.Controls.Add(myInput)
A) Is there a better way to add controls dynamically and possition the corresponding HTML around them?
B) If I don't need the functionality of an asp server control is it a sin to just write out the HTML for an old sytle HTML Input element enclosed in the other HTML needed. Also will an ASP.Net server control still function to post back the form?
C) As I will need to loop through the contents of the form when posted back does either of the above two provide an major problems?
I can see that this is an area worth investing some time in to get right, so any help would be appreciated.