Office 365 – SharePoint Online – Only Content controls are allowed directly in a content page that contains Content controls

Office 365 - SharePoint - Exception on page which is created from new custom page layout
Office 365 - SharePoint - Exception on page which is created from new custom page layout

Hi All

New problem in SharePoint Online world in classic mode 🙂 and solution :).

In this article I will explain how the exception “Only Content controls are allowed directly in a content page that contains Content controls.” occurs and solution to it.

Background : For our SharePoint online application (in classic mode) we were working on new custom page layout. Our page layout is very simple and as such no major changes. So we just downloaded OOB “Article Page” layout and opened it in Visual Studio, modified it and manually uploaded in “Master Page” gallery. Set the “Content Type” as “Page Layout” content type and “Associated Content Type” as our custom content type. We made page layout available from the “Page Layout and Site Template Settings” for creating the pages.

So next step is to create the content page from our custom page layout and verify it. Content page successfully get created but when we open the page it throws an following exception as

Figure 1 : Office 365 – SharePoint – Exception on page which is created from new custom page layout

Sorry, something went wrong
Only Content controls are allowed directly in a content page that contains Content controls.
TECHNICAL DETAILS

Troubleshoot issues with Microsoft SharePoint Foundation.
Correlation ID: 034a449d-d02b-2000-1648-733d4593b008
Date and Time: 11/22/2015 7:46:39 PM

Only the above exception and not much details. Googled bit but no luck. Also went through the page layout in visual studio again but seems to be no issues.

So finally I downloaded the our page layout from “Master Page” gallery and surprisingly found that there were below extra commented code added at the bottom of the page layout after the closing section of “PlaceHolderMain” control place holder:

<%--<div class="captioned-image">
<div class="image">
<PublishingWebControls:RichImageField FieldName="PublishingPageImage" runat="server"/>
</div>
<div class="caption">
<PublishingWebControls:RichHtmlField FieldName="PublishingImageCaption"  AllowTextMarkup="false" AllowTables="false" AllowLists="false" AllowHeadings="false" AllowStyles="false" AllowFontColorsMenu="false" AllowParagraphFormatting="false" AllowFonts="false" PreviewValueSize="Small" AllowInsert="false" AllowEmbedding="false" AllowDragDrop="false" runat="server"/>
</div>
</div>--%>

Root Cause / Solution : This type of issue there also previously we have in on premises but with different exception message like “No parameter less constructor defined for this object”.

After again going through the page layout, it seems to be problem with casing of tag. There were mismatch between casing of opening and closing of tag.

Opening tag is – : C in Content is capital case and
Closing tag is – : c in Content is small case

It should always be capital ‘C’ in Content of opening as well as in closing tag like
<asp:Content> </asp:Content>

We corrected our page layout and problem went away 🙂

Thanks for reading  🙂

Keep reading, share your thoughts, experiences. Feel free to contact us to discuss more. If you have any suggestion / feedback / doubt, you are most welcome.

Stay tuned on Knowledge-Junction, will come up with more such articles

Prasham Sabadra

LIFE IS VERY BEAUTIFUL. ENJOY THE WHOLE JOURNEY :) Founder of Microsoft 365 Junction, Speaker, Author, Learner, Developer, Passionate Techie. Certified Professional Workshop Facilitator / Public Speaker. Believe in knowledge sharing. Around 20+ years of total IT experience and 17+ years of experience in SharePoint and Microsoft 365 services Please feel free me to contact for any SharePoint / Microsoft 365 queries. I am also very much interested in behavioral (life changing) sessions like motivational speeches, Success, Goal Setting, About Life, How to live Life etc. My book - Microsoft 365 Power Shell hand book for Administrators and Beginners and 100 Power Shell Interview Questions - https://www.amazon.in/Microsoft-Administrators-Beginners-Interview-Questions/dp/9394901639/ref=tmm_pap_swatch_0?_encoding=UTF8&qid=1679029081&sr=8-11

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Microsoft 365

Subscribe now to keep reading and get access to the full archive.

Continue reading