我已经完成了我的 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
中的表单标签,母版页上的表单标记就足够了。
关于c# - 获取一个页面只能有一个服务器端表单标签错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31615872/