一个页面只能有一个服务器端的Form标签

时间:2011-04-30 14:07:16

标签: asp.net html master-pages

我在主页面上添加了带有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>

2 个答案:

答案 0 :(得分:3)

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

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

会在尝试添加表单标记时导致问题。此处您不需要此表单,因为母版页中的表单标记非常合适。

答案 1 :(得分:0)

    private int Foo()
    {
        while (true)
        {

        }
    }