简体   繁体   English

类型为'TextBox'的控件'ctl07'必须放置在带有runat = server的表单标记中。

[英]Control 'ctl07' of type 'TextBox' must be placed inside a form tag with runat=server.

I have a problem you can see at the title. 我有一个问题可以在标题上看到。

 <form id="form1" runat="server">
    <div>
        <br />
        <asp:GridView ID="GridView1" runat="server">
        </asp:GridView>
        <asp:TextBox ID="mac_id" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" 
            Text="Temp Ekle" />
    </div>
    </form>

inside aspx.cs i create a table and i insert some values from database to this text box called "mac_id". 在aspx.cs中,我创建了一个表,并将一些值从数据库插入到名为“ mac_id”的此文本框中。

TableCell cel = new TableCell();
mac_id.Text = Convert.ToString(myDataTable.Rows[0][2]);
cel.Controls.Add(mac_id);
rw.Cells.Add(cel);

it is inside the form tag and it is runat="server".This is the code that using mac_id textbox.there is no code that manipulate that textbox.I only want to show the user the id.I am not using any render control or something that textbox has.I also check the other solutins but they are all using render or writer i am not thats because i open a new question. 它在form标记内,并且是runat =“ server”。这是使用mac_id文本框的代码。没有可操纵该文本框的代码。我只想向用户显示id。我没有使用任何渲染控件或文本框具有的内容。我还检查了其他solutins,但它们都使用了render或writer,我不是那是因为我打开了一个新问题。 I hope i can explain my problem enough.Thanks for helping. 我希望我能解释我的问题。谢谢您的帮助。

You can avoid this execption by overriding VerifyRenderingInServerForm 您可以通过重写VerifyRenderingInServerForm来避免执行此操作

public override void VerifyRenderingInServerForm(Control control)
{
  /* Confirms that an HtmlForm control is rendered for the specified ASP.NET
     server control at run time.
     Hence, no exception. */
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 类型为&#39;TextBox&#39;的控件&#39;ctl00_txtDebug&#39;必须放置在带有runat = server的表单标记中 - Control 'ctl00_txtDebug' of type 'TextBox' must be placed inside a form tag with runat=server 'Button' 类型的控件 'ctl02' 必须放置在带有 runat=server 的表单标签内 - Control 'ctl02' of type 'Button' must be placed inside a form tag with runat=server 类型为“ RadioButton”的控件“ ctl00”必须置于带有runat = server的表单标记中 - Control 'ctl00' of type 'RadioButton' must be placed inside a form tag with runat=server 类型为“ DataControlLinkBut​​ton”的控件“ DataLoading1_gdvDataGroups_ctl01_ctl00”必须置于带有runat = server的表单标记中 - Control 'DataLoading1_gdvDataGroups_ctl01_ctl00' of type 'DataControlLinkButton' must be placed inside a form tag with runat=server 类型为&#39;TextBox&#39;的控件&#39;MainContent_forenameTxt&#39;必须放置在带有runat = server的表单标签中 - Control 'MainContent_forenameTxt' of type 'TextBox' must be placed inside a form tag with runat=server 类型为“ HtmlEditorExtender”的控件必须放在带有runat = server的表单标签中 - Control of type 'HtmlEditorExtender' must be placed inside a form tag with runat=server &#39;TextBox&#39; 类型的控件 &#39;txtUserName&#39; 必须放置在带有 runat=server 的表单标签中 - Control 'txtUserName' of type 'TextBox' must be placed inside a form tag with runat=server 必须将&#39;GridView&#39;放在带有runat = server的表单标记内。 - 'GridView' must be placed inside a form tag with runat=server. 为&lt;%= @ Html.DropDownList%&gt;获取异常{“类型为“按钮”的控件&#39;按钮1”必须放置在带有runat = server的表单标记中。”} - Getting exception for <%=@Html.DropDownList%> {“Control 'Button1' of type 'Button' must be placed inside a form tag with runat=server.”} &#39;Button&#39; 类型的控件 &#39;ContentPlaceHolder1_Button1&#39; 必须放置在带有 runat=server 的表单标签内 - Control 'ContentPlaceHolder1_Button1' of type 'Button' must be placed inside a form tag with runat=server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM