what's the best way to add (web)controls at runtime ??
Add them to the Controls collection of the parent object. Here is a
simple example of how you can add a Label control to the web form.
How can I do that with a textbox, I'll get an error saying there must
be positioned in a formtag with runat = "server", but where if I
generate in at runtime??
You'll have to add it to the HtmlForm control. The following C# code
will add a textbox to the form:
TextBox tbx=new TextBox();
tbx.Text="Hello";
Page.FindControl("Form1").Controls.Add(tbx);
The Text property of the TextBox hold the value displayed in the
textbox. Just assign the XML string to this property. If you have an
XmlDocument instance holding the XML data you can do this to display the
entire XML document in the TextBox:
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.