Home » FAQ » ASP.NET » Controls » Why do I get error message ‘The control ‘_ctl1’ of type ‘TextBox’ must be inside a form label with runat=server’ while trying to place a control inside a form dynamically
You are probably adding the textbox into the Page directly instead of adding it to the Page’s form. Try doing this:
VB.NET
Me.Page.Controls(1).Controls.Add(txtboxctrl)
C#
this.Page.Controls[1].Controls.Add(txtboxctrl);
Platform BlazorASP.NETWinFormsWPF.NET MAUI
Question *
Answer (Optional)
Email (Optional)
Email address is only for further clarification on your FAQ request. It will not be used for any other purpose.
Please leave this field empty.
Share with