简体   繁体   中英

'TextBox' must be placed inside a form tag with runat=server"

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:

 <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>

Just remove the form tag from your content page - the form tag on the master page will be sufficient. You will need the ContentPlaceHolder tags on the master page to be within the form for this to work.

like

 <form id="form1" runat="server">
       <div>
           <asp:ContentPlaceHolder id="bodycontent" runat="server">

           </asp:ContentPlaceHolder>
       </div>
 </form>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM