【问题标题】:A page can have only one server-side Form tag一个页面只能有一个服务器端 Form 标签
【发布时间】:2011-08-16 01:59:14
【问题描述】:

我在母版页中添加了一个带有 html 代码的页面,但当我启动该页面时出现了这个错误。我想知道我做错了什么!??!

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

【问题讨论】:

    标签: asp.net html master-pages


    【解决方案1】:

    ASP.NET Web 窗体不允许您在一个页面中放置多个 form 标记 - 您的母版页包含该 form 标记,因此:

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

    在尝试添加表单标签时会导致问题。无论如何,您在这里不需要此表单,因为您的母版页中的表单标记已经足够了。

    【讨论】:

      【解决方案2】:
      <head runat="server">
          <title></title>
      </head>
      <body style="direction:rtl;width:100%;background-color:#808080">
          <form id="frmLevel2" runat="server">
              <div dir="ltr" style="width:1000px;">
                  <asp:Button ID="btnExit" runat="server" OnClick="btnExit_Click" Text="خروج" />
              </div>
              <div>
                  <asp:GridView ID="GVLevel2" runat="server" Font-Names="Times New Roman" Font-Size="9pt" Width="700px" AllowPaging="True" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal">
                      <AlternatingRowStyle BackColor="#F7F7F7" />
                      <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
                      <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
                      <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
                      <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
                      <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
                      <SortedAscendingCellStyle BackColor="#F4F4FD" />
                      <SortedAscendingHeaderStyle BackColor="#5A4C9D" />
                      <SortedDescendingCellStyle BackColor="#D8D8F0" />
                      <SortedDescendingHeaderStyle BackColor="#3E3277" />
                  </asp:GridView>
              </div>
              <div>
                  <asp:Label ID="erorlabel" runat="server"></asp:Label>
                  <asp:Label ID="lblresult" runat="server"></asp:Label>
              </div>
          </form>
      </body>
      </html>
      
      My Error is " A page can have only one server-side Form tag. " too
      i  don't have master page 
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-12-07
        • 2020-05-26
        • 1970-01-01
        • 2015-10-15
        • 2011-02-24
        • 1970-01-01
        相关资源
        最近更新 更多