2

尝试在 localhost 上运行我的项目时出现此错误

异常详细信息:System.Web.HttpException:一个页面只能有一个服务器端 Form 标签

这是我的ASP.NET表格

 <form id="consultationform" runat="server">

    <%-- Consultation  --%>
    <%-- Name --%>
    <asp:Label ID="namelabel" runat="server" Text="Name"></asp:Label>
    <asp:TextBox ID="namebox" runat="server"></asp:TextBox><br />

    <%-- email --%>
    <asp:Label ID="emaillabel" runat="server" Text="Email"></asp:Label>
    <asp:TextBox ID="emailbox" runat="server"></asp:TextBox><br />

    <%-- restaurant --%>
    <asp:Label ID="restaurantlabel" runat="server" Text="Restaurant"></asp:Label>
    <asp:TextBox ID="restaurantbox" runat="server"></asp:TextBox><br />

    <%-- Address --%>
    <asp:Label ID="addresslabel" runat="server" Text="Address"></asp:Label>
    <asp:TextBox ID="addressbox1" runat="server"></asp:TextBox><br />
    <asp:TextBox ID="addressbox2" runat="server"></asp:TextBox><br />
    <asp:TextBox ID="addressbox3" runat="server"></asp:TextBox><br />

    <%-- County --%>
    <asp:Label ID="countylabel" runat="server" Text="County"></asp:Label>
    <asp:DropDownList ID="countrydropdown" runat="server" 
    DataSourceID="CountySqlDataSource" DataTextField="CountyName" 
    DataValueField="CountyName" AppendDataBoundItems="True" AutoPostBack="True">
    <asp:ListItem Value="" Text="Select a County"></asp:ListItem>
    </asp:DropDownList>
<asp:SqlDataSource ID="CountySqlDataSource" runat="server" 
    ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
    SelectCommand="SELECT [CountyName] FROM [Counties]"></asp:SqlDataSource>
<br />

    <%-- Telephone --%>
    <asp:Label ID="telephonelabel" runat="server" Text="Telephone"></asp:Label>
    <asp:TextBox ID="telephonebox" runat="server"></asp:TextBox><br />

    <%-- Calendar --%>
    <asp:Label ID="datelabel" runat="server" Text="Date (What suits you?)"></asp:Label><asp:Calendar
        ID="Calendar1" runat="server"></asp:Calendar><br />

    <%-- Additional Info --%>
    <asp:Label ID="infolabel" runat="server" Text="Additional Information (That may help us further)"></asp:Label><br />
    <asp:TextBox ID="infobox" runat="server"></asp:TextBox><br />

    <%-- Menu Upload --%>
    <asp:Label ID="menulabel" runat="server" Text="Menu"></asp:Label><asp:FileUpload
        ID="FileUpload1" runat="server" /><br />

    <%-- Book Button --%>
    <asp:Button ID="bookbtn" runat="server" Text="Book Now" />

    </form>

我不明白为什么会这样。我在页面上只有一个表单标签。非常感谢您对此事的任何帮助。

form应该注意,如果我删除标签,页面会完全呈现。

4

2 回答 2

1

如果您使用的是母版页,请从您的网络表单中删除该表单,并在母版页表单中添加一个内容占位符。

在您的网络表单中使用该内容占位符,就像您尝试使用表单一样。

您可能需要单击表单中内容占位符右侧的小箭头才能启用它。

于 2013-11-20T14:41:08.787 回答
0

在您的母版页中,您至少应该有:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs"Inherits="WebApplication1.Site1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

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

然后,您可以从项目中删除所有其他表单标签,因为 master 有一个正在使用中。记得在正文内容占位符中也正确添加内容页面。

于 2013-11-20T14:55:28.053 回答