Asp.net 一个页面只能有一个服务器端表单标记。(如何在母版页中添加多个表单)

Asp.net 一个页面只能有一个服务器端表单标记。(如何在母版页中添加多个表单),asp.net,master-pages,Asp.net,Master Pages,嗨,我在母版页中使用表单,因为我想显示数据库表中的下拉菜单。这是我的代码 <body> <form id="form1" runat="server"> <div class="container-fluid"> <nav class="navbar navbar-default"> <div class="navbar-header">

嗨,我在母版页中使用表单,因为我想显示数据库表中的下拉菜单。这是我的代码

<body>
      <form id="form1"  runat="server">
        <div class="container-fluid">
            <nav class="navbar navbar-default">
                <div class="navbar-header">
                    <div class="navbar-brand logo">
                         <a href="home.aspx"><span>Ads</span>Valley</a>
                    </div>
                </div>
                <div class="collapse navbar-collapse">
                    <asp:DropDownList runat="server" ID="DropDownCity" CssClass="DropDownCity" >
                    </asp:DropDownList>
                    <asp:DropDownList runat="server" ID="DropDownCountry" CssClass="DropDownCity">
                    </asp:DropDownList>
                    <asp:DropDownList runat="server" ID="DropDownCate" CssClass="DropDownCity">
                    </asp:DropDownList>
                      <asp:HyperLink ID="Pending" NavigateUrl="~/Requests.aspx" runat="server" CssClass="PendingReq">Pending Request<asp:Label runat="server" ID="Spam" CssClass="badge"></asp:Label></asp:HyperLink>
                    <asp:HyperLink ID="ButtonLogout" runat="server" CssClass="Adminlogout" NavigateUrl="~/Logout.aspx">Logout</asp:HyperLink> 
                </div  
            </nav>
        </div>
        <div class="main-banner banner text-center">
        <div class="container">
            <h1>Sell <span class="segment-heading">Anything Online For Free </span>With AdsValley</h1>
            <h3><strong><span class="auto-style2">Welcome Admin</span></strong></h3>
            <p>
                &nbsp;</p>

        </div>
    </div>
           </form>       
    <asp:ContentPlaceHolder id="head" runat="server"></asp:ContentPlaceHolder>
        <asp:ContentPlaceHolder id="Content" runat="server"></asp:ContentPlaceHolder>
       <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
 </asp:ContentPlaceHolder>   
</body>
</html>

未决请求
注销

从内容页中删除您的
标记。然后阅读asp.net如何处理表单:Web表单中不可能有多个表单。可以,但其中只有一个可以标记为
runat=“server”
,当然,它们不能相互嵌套。如果这对您来说是一个问题,那么Web表单对您来说不是正确的解决方案,您应该检查或使用一个新的客户端框架(Angular或React等)与后端对话。事实上,无论如何,您都应该考虑离开Web表单。
<%@ Page Title="" Language="C#" MasterPageFile="~/Admin_MasterPage.master" AutoEventWireup="true" CodeFile="Requests.aspx.cs" Inherits="Requests" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <form id="form1" runat="server">
   <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="AdsId" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
   <Columns>
            <asp:BoundField DataField="Country" HeaderText="Country" ItemStyle-Width="150" />
            <asp:BoundField DataField="Cat_ID" HeaderText="Category ID" ItemStyle-Width="150" />
            <asp:BoundField DataField="Ad_Title" HeaderText="Ads Title" ItemStyle-Width="150" />
             <asp:BoundField DataField="Brand" HeaderText="Brand" ItemStyle-Width="150" />
            <asp:BoundField DataField="Model" HeaderText="Model" ItemStyle-Width="150" />
            <asp:BoundField DataField="Price" HeaderText="Price" ItemStyle-Width="150" />
            <asp:BoundField DataField="Description" HeaderText="Description" ItemStyle-Width="150" />
            <asp:BoundField DataField="Conditions" HeaderText="Conditions" ItemStyle-Width="150" />
           <asp:BoundField DataField="Owner" HeaderText="Owner" ItemStyle-Width="150" />
           <asp:BoundField DataField="Contact" HeaderText="Contact" ItemStyle-Width="150" />
           <asp:BoundField DataField="City" HeaderText="City" ItemStyle-Width="150" />
           <asp:BoundField DataField="Date" HeaderText="Date" ItemStyle-Width="150" />
          <asp:BoundField DataField="ImageName" HeaderText="Image Name" ItemStyle-Width="150" />
            <asp:BoundField DataField="ImageContent" HeaderText="Image Content" ItemStyle-Width="150" />
           <asp:BoundField DataField="Photo1" HeaderText="Photo 1" ItemStyle-Width="150" />
           <asp:BoundField DataField="Photo2" HeaderText="Photo 2" ItemStyle-Width="150" />
           <asp:BoundField DataField="Photo3" HeaderText="Photo 3" ItemStyle-Width="150" />
        <asp:CommandField ButtonType="Link" ShowEditButton="true" ShowDeleteButton="true"
                ItemStyle-Width="100" />
       <asp:CommandField  ButtonType="Link" EditText="Accept" ShowEditButton="true"/>
        </Columns>
         </asp:GridView>
     <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:dbconnection %>"
          SelectCommand="SELECT [Country], [Cat_ID], [Ad_Title], [Brand], [Model], [Price], [Description], [Owner], [ImageName], [ImageContent], [Photo1], [Contact], [City], [Date], [Owner_ID], [Conditions], [Photo2], [Photo3] FROM [Ads]" UpdateCommand="UPDATE Ads SET Country = @Country, Cat_ID = @catId, Ad_Title=@tite, Brand=@brand, Model=@mod, Price=@prc, Description=@des, Conditions=@cond, Owner=@own, Contact=@cont, City=@City, Date=@d, ImageName=@imgn, ImageContent=@imgCot, Photo1=@ph1, Photo2=@ph2, Photo3=@ph3 WHERE AdsId = @AdsId"
        DeleteCommand="DELETE FROM Country WHERE AdsId = @AdsId">
       <%-- define paramerters here--%>
         <UpdateParameters>
             <asp:Parameter Name="AdsId" Type="Int32" />
             <asp:Parameter Name="Country" Type="String" />
             <asp:Parameter  Name="catId" Type="Int32"/>
             <asp:Parameter Name="title" Type="String" />
             <asp:Parameter Name="brand" Type="String" />
             <asp:Parameter Name="mod" Type="String" />
             <asp:Parameter Name="prc" Type="Int32" />
             <asp:Parameter Name="des" Type="String" />
              <asp:Parameter Name="cond" Type="String" />
             <asp:Parameter Name="own" Type="String" />
             <asp:Parameter Name="cont" Type="String" />
             <asp:Parameter Name="city" Type="String" />
             <asp:Parameter Name="d" Type="DateTime" />
             <asp:Parameter Name="imgn" Type="String" />
             <asp:Parameter Name="imgCot" Type="String" />
             <asp:Parameter Name="ph1" Type="String"/>
             <asp:Parameter Name="ph2" Type="String"/>
             <asp:Parameter Name="ph3" Type="String"/>
         </UpdateParameters>
         <DeleteParameters>
             <asp:Parameter Name="AdsId" Type="Int32" />
         </DeleteParameters>
     </asp:SqlDataSource>   
 </form>
</asp:Content>