Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
2k views
in SharePoint Server by 19 22 32

I got this error "Only Content controls are allowed directly in a content page that contains Content controls." after checking in and publshing the Page layout In SharePoint 2019!! 

I havec checked other pagelayouts that were working without any issue!!

How can i fix this error


1 Answer

1 like 0 dislike
by 159 200 383
selected by
 
Best answer

Solving: Only Content controls are allowed directly on a content page

I have faced this error Only Content controls are allowed directly in a content page with SharePoint Page Layout that was not well-formatted!

In my case, the issue occurred due to there being auto-generated tags added (<HTML> & <body> content) after </asp:content>, so try to remove all the spaces, and line breaks after the last closing tag.

Only Content controls are allowed directly in a content page

Also, to avoid this error Only Content controls are allowed directly in a content page, try to do the following cases:

  • All of your content, including static HTML should be added inside <asp:content contentplaceholderid="PlaceHolderMain" runat="server">
  • In some cases, you may need to change lower-case <asp:content> to upper-case <asp:Content>.
  • Ensure that any content is inside <asp:Content> tags
  • Also check your <asp:Content> has correct ContentPlaceHolderID

      <asp:content contentplaceholderid="PlaceHolderMain" runat="server">
    
  • Check there are no white spaces around <asp:Content>
If you don’t ask, the answer is always NO!
...