Control ‘ctl00_TextBox1’ of type ‘TextBox’ must be placed inside a form tag with runat=server

asp.netmaster-pages

When a form with a run at server is added there will be two forms with runat server and another error occurs. Can some one give me an idea. Thankx in advance.

The details of the error are as follows.

Control 'ctl00_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 'ctl00_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
'ctl00_TextBox1' of type 'TextBox'
must be placed inside a form tag with
runat=server.]
System.Web.UI.Page.VerifyRenderingInServerForm(Control
control) +2052287
System.Web.UI.WebControls.TextBox.AddAttributesToRender(HtmlTextWriter
writer) +49
System.Web.UI.WebControls.WebControl.RenderBeginTag(HtmlTextWriter
writer) +17
System.Web.UI.WebControls.TextBox.Render(HtmlTextWriter
writer) +17
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter
writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter
writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter
writer) +22
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter
writer, ICollection children) +199
System.Web.UI.Control.RenderChildren(HtmlTextWriter
writer) +20
System.Web.UI.Control.Render(HtmlTextWriter
writer) +7
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter
writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter
writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter
writer) +22
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter
writer, ICollection children) +199
System.Web.UI.Control.RenderChildren(HtmlTextWriter
writer) +20
System.Web.UI.Page.Render(HtmlTextWriter
writer) +26
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter
writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter
writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter
writer) +22
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean
includeStagesAfterAsyncPoint) +2558

Version Information: Microsoft .NET
Framework Version:2.0.50727.1873;
ASP.NET Version:2.0.50727.1433

Best Answer

The error states the problem

Correct

<form id="frm" runat="server">
    <asp:TextBox id="txt" runat="server" />
</form>

Incorrect

<asp:TextBox id="txt" runat="server" />
<form id="frm" runat="server">
</form>
Related Topic