![](/img/trans.png)
[英]Control 'ctl00_txtDebug' of type 'TextBox' must be placed inside a form tag with runat=server
[英]Control 'ctl07' of type 'TextBox' must be placed inside a form tag with runat=server.
我有一个问题可以在标题上看到。
<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>
在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);
它在form标记内,并且是runat =“ server”。这是使用mac_id文本框的代码。没有可操纵该文本框的代码。我只想向用户显示id。我没有使用任何渲染控件或文本框具有的内容。我还检查了其他solutins,但它们都使用了render或writer,我不是那是因为我打开了一个新问题。 我希望我能解释我的问题。谢谢您的帮助。
您可以通过重写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.