Search code examples
asp.nethtmlmaster-pages

A page can have only one server-side Form tag


i added a page with html code to a master page and i got that mistake when i launched the page. i wonder what i did wrong!??!

    <%@ Page Title="" Language="C#" MasterPageFile="~/YourGuruMaster.master" AutoEventWireup="true" CodeFile="YourGuru.aspx.cs" Inherits="YourGuru" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
        <style type="text/css">
            .style3
            {
                width: 114px;
            }
        .style4
        {
            width: 293px;
        }
        .style5
        {
            width: 126px;
        }
        </style>
    </asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <form id="form1" runat="server">

      <div align="center">
        <p>
            <asp:TextBox ID="Question" runat="server" style="margin-left: 0px" Width="584px"></asp:TextBox>
        </p>
       </div>


    <div align="center">
        <table style="width: 553px">
             <tr>
                    <td class="style3">
                        <asp:Button ID="Ask" runat="server" Text="שאל" Width="50px" />     
                        </td>

                    <td class="style4">
                        <asp:DropDownList ID="DropDownList1" runat="server">
                        </asp:DropDownList>
                        &nbsp   &nbsp   &nbsp
                        <asp:DropDownList ID="DropDownList2" runat="server">
                        </asp:DropDownList>
                         &nbsp   &nbsp   &nbsp
                         <asp:DropDownList ID="DropDownList3" runat="server">
                          </asp:DropDownList>  
                       </td>

                        <td class="style5">
                            <asp:Button ID="Answer" runat="server" Text="ענה" Width="50px" />
                        </td>
                 </tr>
            </table>
    </div>


  </form>
</asp:Content>

Solution

  • ASP.NET Web Forms won't let you put more than one form tag in a page - your master page contains that form tag, so this:

    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <form id="form1" runat="server">
       <div align="center">
    

    will cause problems as it's trying to add a form tag. You don't need this form here anyways as the form tag in your master page is quite adequate.