Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Error: Content controls are allowed only in content page that references a master page

Tags:

asp.net

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.

like image 621
Such Avatar asked Nov 15 '25 09:11

Such


2 Answers

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>
<body>

tags then the likelihood is that you've created a new page rather than a new page based off a masterpage.

like image 95
Full Time Skeleton Avatar answered Nov 17 '25 07:11

Full Time Skeleton


I ran into the same issue.

For my case, these 3 steps needs to be followed to fix it:

  1. The .aspx file doesn't come under a MasterPage which means that this attribute is absent in the .aspx file MasterPageFile="~/MyBasePage.Master" like this. Make sure the attribute is there.

<%@ Page Language="C#" MasterPageFile="~/MyBasePage.Master AutoEventWireup="true" CodeBehind="Home.aspx.cs" Inherits="Public.Home" %>

  1. The Master page needs to have the same ContentPlaceHolder like this to hold the HTML

<asp:ContentPlaceHolder ID="ContentHeader" runat="server"></asp:ContentPlaceHolder>

  1. The .aspx file needs to have a Content tag with the ContentPlaceHolderID same as the above ID

<asp:Content ID="Content1" ContentPlaceHolderID="ContentHeader" runat="server"></asp:Content>

like image 28
Venkata Krishna Avatar answered Nov 17 '25 08:11

Venkata Krishna



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!