[英]ASP.NET Error: Content controls are allowed only in content page that references a master page
I received the error in the title as a result of the following page:由于以下页面,我收到了标题中的错误:
<asp:Content ID="Content" ContentPlaceHolderID="ContentPlaceHolder" Runat="Server">
<atlas:ScriptManager ID="ScriptManager" runat="server">
</atlas:ScriptManager>
In this page I use AJAX controls.在此页面中,我使用 AJAX 控件。
The page that you've put the content control is not a master page based page.您放置内容控件的页面不是基于母版页的页面。 Check the top of the page, if you've got html like检查页面顶部,如果你有 html 喜欢
<html>
<body>
tags then the likelihood is that you've created a new page rather than a new page based off a masterpage.标签那么可能是您创建了一个新页面,而不是基于母版页的新页面。
I ran into the same issue.我遇到了同样的问题。
For my case, these 3 steps needs to be followed to fix it:就我而言,需要遵循以下 3 个步骤来修复它:
MasterPageFile="~/MyBasePage.Master"
like this. .aspx 文件不在 MasterPage 下,这意味着 .aspx 文件MasterPageFile="~/MyBasePage.Master"
不存在此属性,就像这样。 Make sure the attribute is there.确保属性在那里。 <%@ Page Language="C#" MasterPageFile="~/MyBasePage.Master AutoEventWireup="true" CodeBehind="Home.aspx.cs" Inherits="Public.Home" %>
ContentPlaceHolder
like this to hold the HTML母版页需要像这样具有相同的ContentPlaceHolder
来保存 HTML <asp:ContentPlaceHolder ID="ContentHeader" runat="server"></asp:ContentPlaceHolder>
ContentPlaceHolderID
same as the above ID
.aspx 文件需要有一个 Content 标签,其ContentPlaceHolderID
与上述ID
相同<asp:Content ID="Content1" ContentPlaceHolderID="ContentHeader" runat="server"></asp:Content>
Just use those lines, problem will be solved.只要使用这些线,问题就会解决。
<%@ Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="YourPageCode.aspx.cs" Inherits="ProjectName.PageName" %>
<asp:Content ID="ContentId" ContentPlaceHolderID="PlaceholderID" runat="server">Your page content here</asp:Content>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.