Problem dynamically loading a user control....
From: José Joye (jose.joye_at_KILLTHESPAMSbluewin.ch)
Date: 09/16/04
- Next message: Ed West: "FormsAuthentication.SignOut not working"
- Previous message: Kenneth Keeley: "Re: XML Address Book in DataGrid"
- Next in thread: srini: "RE: Problem dynamically loading a user control...."
- Reply: srini: "RE: Problem dynamically loading a user control...."
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 16 Sep 2004 07:53:43 +0200
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.ascx file.
In an aspx file I placed the following in the Page_Load method:
private void Page_Load(object sender, System.EventArgs e)
{
Control uc2 = LoadControl("MyTestCtrl2.ascx");
Page.Controls.Add(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.HttpException: 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.Page.VerifyRenderingInServerForm(Control control)
System.Web.UI.WebControls.TextBox.AddAttributesToRender(HtmlTextWriter
writer)
System.Web.UI.WebControls.WebControl.RenderBeginTag(HtmlTextWriter
writer)
System.Web.UI.WebControls.TextBox.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
System.Web.UI.Control.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
System.Web.UI.Control.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Page.ProcessRequestMain()
Thanks,
José
- Next message: Ed West: "FormsAuthentication.SignOut not working"
- Previous message: Kenneth Keeley: "Re: XML Address Book in DataGrid"
- Next in thread: srini: "RE: Problem dynamically loading a user control...."
- Reply: srini: "RE: Problem dynamically loading a user control...."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|