获取一个页面只能有一个服务器端Form标签报错
Getting A page can have only one server-side Form tag Error
我已经完成 MasterPage
并使用此 MasterPage
创建了一个新的 .aspx
页面。但是每当我尝试将 RadioButton
添加到 .aspx
页面时,它都会向我生成此错误:
Control 'head_ctl00' of type 'RadioButton' must be placed inside a
form tag with runat=server.
我试图添加一个表单标签,但出现了这个错误!
A page can have only one server-side Form tag.
我很困惑如何解决这个问题!任何的想法 ?
如果您需要我的 .aspx
页面:
<%@ Page Title="" Language="C#" MasterPageFile="~/MySite.Master" AutoEventWireup="true" CodeBehind="Registration.aspx.cs" Inherits="MyWebsite.Registration" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<form id="frm" runat="server">
<asp:RadioButton runat="server"></asp:RadioButton>
</form>
</asp:Content>
您已将 RadioButton
插入到 head
占位符中,而 MasterPage
文件中没有表单标记。您应该将 RadioButton
放在另一个 PlaceHolder
中,例如 MainContent
或 FeaturedContent
。此外,您不需要 ContentPages
中的表单标签,母版页上的表单标签就足够了。
我已经完成 MasterPage
并使用此 MasterPage
创建了一个新的 .aspx
页面。但是每当我尝试将 RadioButton
添加到 .aspx
页面时,它都会向我生成此错误:
Control 'head_ctl00' of type 'RadioButton' must be placed inside a form tag with runat=server.
我试图添加一个表单标签,但出现了这个错误!
A page can have only one server-side Form tag.
我很困惑如何解决这个问题!任何的想法 ?
如果您需要我的 .aspx
页面:
<%@ Page Title="" Language="C#" MasterPageFile="~/MySite.Master" AutoEventWireup="true" CodeBehind="Registration.aspx.cs" Inherits="MyWebsite.Registration" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<form id="frm" runat="server">
<asp:RadioButton runat="server"></asp:RadioButton>
</form>
</asp:Content>
您已将 RadioButton
插入到 head
占位符中,而 MasterPage
文件中没有表单标记。您应该将 RadioButton
放在另一个 PlaceHolder
中,例如 MainContent
或 FeaturedContent
。此外,您不需要 ContentPages
中的表单标签,母版页上的表单标签就足够了。