类型为'TextBox'的控件'ctl07'必须放置在带有runat = server的表单标记中. [英] Control 'ctl07' of type 'TextBox' must be placed inside a form tag with runat=server.

查看:56
本文介绍了类型为'TextBox'的控件'ctl07'必须放置在带有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>

在aspx.cs内,我创建了一个表,并将数据库中的一些值插入到此名为"mac_id"的文本框中.

inside aspx.cs i create a table and i insert some values from database to this text box called "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,我不是那是因为我打开了一个新问题.我希望我能解释我的问题.感谢您的帮助.

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. I hope i can explain my problem enough.Thanks for helping.

推荐答案

您可以通过重写VerifyRenderingInServerForm

You can avoid this execption by overriding 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. */
}

这篇关于类型为'TextBox'的控件'ctl07'必须放置在带有runat = server的表单标记中.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆