[英]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.