vb.net 'TextBox' 必须放置在带有 runat=server 的表单标签内”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31738503/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'TextBox' must be placed inside a form tag with runat=server"
提问by Daniel Darko
hey guys i'm building a website for a school assignment and i want to create a multi line text box but when i do i get the error "'TextBox' must be placed inside a form tag with runat=server" I've looked it over and it wouldn't go away by inserting a form tag with runat server before the text box code. how can i fix this? here's the code:
嘿伙计们,我正在为学校作业建立一个网站,我想创建一个多行文本框,但是当我这样做时,我收到错误消息“'TextBox' 必须放置在带有 runat=server 的表单标签中”我看过了它结束了,它不会通过在文本框代码之前插入带有 runat 服务器的表单标签而消失。我怎样才能解决这个问题?这是代码:
<asp:Content ID="Content2" ContentPlaceHolderID="body" Runat="Server">
<form id="Form1" runat="server">
<div id="body">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
</form>
</asp:Content>
回答by Tushar
Just remove the form tag from your content page - the form tag on the master page will be sufficient. You will need the ContentPlaceHoldertags on the master page to be within the form for this to work.
只需从您的内容页面中删除表单标签 - 母版页上的表单标签就足够了。您将需要ContentPlaceHolder母版页上的标签位于表单中才能使其工作。
like
喜欢
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder id="bodycontent" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>

