Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Add TextBox To Page
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01451101
Message ID:
01451159
Views:
17
>How do you add a textbox to an asp page?
>
>When I try this:
>
>
>        TextBox TextBox1 = new TextBox();
>        this.Controls.Add(TextBox1);
>
>
>I get a page error "Control 'ctl02' of type 'TextBox' must be placed inside a form tag with runat=server. "
>
>Is there no way to do this in C# in the page_load? Or must I do it with tags?

You are trying to add it to the Page (I assume that's what 'this' is?)
Add it instead to the element which will contain it. For example using the default webform generated by VS:
form1.Controls.Add(TextBox1);
Previous
Reply
Map
View

Click here to load this message in the networking platform