Hello,
I'm playing around with dynamically loading user controls ...and having
problems
I created a really simple userControl (in fact contains a plain text box)
and placed it into the MyTestCtrl2.asc x file.
In an aspx file I placed the following in the Page_Load method:
private void Page_Load(objec t sender, System.EventArg s e)
{
Control uc2 = LoadControl("My TestCtrl2.ascx" );
Page.Controls.A dd(uc2);
}
However, I'm always getting this error:
Control '_ctl0_TextBox1 ' of type 'TextBox' must be placed inside a form tag
with runat=server.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Web.Http Exception: Control '_ctl0_TextBox1 ' of
type 'TextBox' must be placed inside a form tag with runat=server.
Source Error:
An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Control '_ctl0_TextBox1 ' of type 'TextBox' must
be placed inside a form tag with runat=server.]
System.Web.UI.P age.VerifyRende ringInServerFor m(Control control)
System.Web.UI.W ebControls.Text Box.AddAttribut esToRender(Html TextWriter
writer)
System.Web.UI.W ebControls.WebC ontrol.RenderBe ginTag(HtmlText Writer
writer)
System.Web.UI.W ebControls.Text Box.Render(Html TextWriter writer)
System.Web.UI.C ontrol.RenderCo ntrol(HtmlTextW riter writer)
System.Web.UI.C ontrol.RenderCh ildren(HtmlText Writer writer)
System.Web.UI.C ontrol.Render(H tmlTextWriter writer)
System.Web.UI.C ontrol.RenderCo ntrol(HtmlTextW riter writer)
System.Web.UI.C ontrol.RenderCh ildren(HtmlText Writer writer)
System.Web.UI.C ontrol.Render(H tmlTextWriter writer)
System.Web.UI.C ontrol.RenderCo ntrol(HtmlTextW riter writer)
System.Web.UI.P age.ProcessRequ estMain()
Thanks,
José
I'm playing around with dynamically loading user controls ...and having
problems
I created a really simple userControl (in fact contains a plain text box)
and placed it into the MyTestCtrl2.asc x file.
In an aspx file I placed the following in the Page_Load method:
private void Page_Load(objec t sender, System.EventArg s e)
{
Control uc2 = LoadControl("My TestCtrl2.ascx" );
Page.Controls.A dd(uc2);
}
However, I'm always getting this error:
Control '_ctl0_TextBox1 ' of type 'TextBox' must be placed inside a form tag
with runat=server.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Web.Http Exception: Control '_ctl0_TextBox1 ' of
type 'TextBox' must be placed inside a form tag with runat=server.
Source Error:
An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Control '_ctl0_TextBox1 ' of type 'TextBox' must
be placed inside a form tag with runat=server.]
System.Web.UI.P age.VerifyRende ringInServerFor m(Control control)
System.Web.UI.W ebControls.Text Box.AddAttribut esToRender(Html TextWriter
writer)
System.Web.UI.W ebControls.WebC ontrol.RenderBe ginTag(HtmlText Writer
writer)
System.Web.UI.W ebControls.Text Box.Render(Html TextWriter writer)
System.Web.UI.C ontrol.RenderCo ntrol(HtmlTextW riter writer)
System.Web.UI.C ontrol.RenderCh ildren(HtmlText Writer writer)
System.Web.UI.C ontrol.Render(H tmlTextWriter writer)
System.Web.UI.C ontrol.RenderCo ntrol(HtmlTextW riter writer)
System.Web.UI.C ontrol.RenderCh ildren(HtmlText Writer writer)
System.Web.UI.C ontrol.Render(H tmlTextWriter writer)
System.Web.UI.C ontrol.RenderCo ntrol(HtmlTextW riter writer)
System.Web.UI.P age.ProcessRequ estMain()
Thanks,
José
Comment