Page Layout Error: 'Only Content controls are allowed directly in a content page that contains Content controls'

Today we were working on some pagelayouts and we got some strange error when we wanted to deploy them. After some testing, we found out that some page layouts were working, some were not. The following error message appeared:

Page Layout Error: 'Only Content controls are allowed directly in a content page that contains Content controls'

When opening the page with SharePoint Designer, we found out that the following tag was added to our page layout:

    1 <html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882">

    2     <head>

    3         <META name="WebPartPageExpansion" content="full">

    4             <!--[if gte mso 9]><xml>

    5 <mso:CustomDocumentProperties>

    6 <mso:PublishingPreviewImage msdt:dt="string">/_catalogs/masterpage/Preview Images/GenericPagePreview.png</mso:PublishingPreviewImage>

    7 <mso:ContentType msdt:dt="string">Pagina-indeling</mso:ContentType>

    8 <mso:MasterPageDescription msdt:dt="string">Linked with Content Type Welcome Page</mso:MasterPageDescription>

    9 <mso:PublishingAssociatedContentType msdt:dt="string">;#Welkomstpagina;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF390064DEA0F50FC8C147B0B6EA0636C4A7D4;#</mso:PublishingAssociatedContentType>

   10 </mso:CustomDocumentProperties>

   11 </xml><![endif]-->

   12         <title>Web Parts 3 columns (PL01)</title>

   13     </head>

After we compared the working page layouts with the page layouts that didnt work, we saw that the

   14 <asp:Content> </asp:Content>

was all lower case. After changing it back to the normal casing, everything worked correctly

Published Tue, Mar 10 2009 1:31 PM by Bas

Comments

# re: Page Layout Error: 'Only Content controls are allowed directly in a content page that contains Content controls'

Monday, August 03, 2009 5:12 AM by Mike Gold

I noticed this could also happen if you put your javascript accidently inside a div with asp:content.  works fine locally, but get the same strange error when I deployed.  It was fixed as soon as I moved the javascript into the first asp content tag (the header)

# re: Page Layout Error: 'Only Content controls are allowed directly in a content page that contains Content controls'

Tuesday, August 11, 2009 10:25 AM by Iggy

Thanks, your post helped me to figure out how to fix this problem after spending several hours in bewilderment.

# re: Page Layout Error: 'Only Content controls are allowed directly in a content page that contains Content controls'

Thursday, August 13, 2009 11:34 PM by Mike

I got this with a mis-formed elements.xml file inside a content type feature.

I had deleted the <FieldDefs></FieldDefs> tag inside the <Elements><ContentType> tags.

'Only Content controls are allowed directly in a content page that contains Content controls' is the error I got as a result.  Nothing to do with my HTML.

# re: Page Layout Error: 'Only Content controls are allowed directly in a content page that contains Content controls'

Friday, August 14, 2009 1:30 AM by Mike

No, what I said about elements.xml was wrong, and what Bas said was right.

But it was *very* subtle for me.

I could use a lowercase asp:content tag happily when pushing aspx files across manually to the 12 hive.

But if I *deployed* a feature containing a page with an asp:content tag, via a wsp, then that page would break, and nothing I did (including fixing the case of the content tag and pushing the file across again) would un-break it.

So I needed to fix the case (change to asp:Content ) and THEN do a redeploy and regenerate the site.

If I deployed with correct case, I could break the case and my page would keep working.  If I deployed with incorrect case, nothing would fix the page.

Argh!  A few hours of my life I'll never get back.

# re: Page Layout Error: 'Only Content controls are allowed directly in a content page that contains Content controls'

Friday, August 14, 2009 4:29 PM by Bas

Mike,

that can be possible because for some reason page layouts sometimes get stored in the content database and sometimes not. Is it possible that you are using some kind of caching mechanism?

By the way: we had the same problems with updating/deploying page layouts and CSS files. After deploying we *sometimes* could modify the same file, and sometimes those changes were reflected, sometimes not, very strange.

I have to mention: I was sure that these files were NOT customized!

# re: Page Layout Error: 'Only Content controls are allowed directly in a content page that contains Content controls'

Tuesday, June 22, 2010 9:47 AM by Wahab Hussain

I am still wondering on this error. Neither of the above solution worked for me.

# re: Page Layout Error: 'Only Content controls are allowed directly in a content page that contains Content controls'

Monday, July 26, 2010 3:23 PM by Bas

Did you place your content controls within content placeholders or not?

# re: Page Layout Error: 'Only Content controls are allowed directly in a content page that contains Content controls'

Wednesday, October 27, 2010 7:56 PM by MassDOT

Mass

# re: Page Layout Error: 'Only Content controls are allowed directly in a content page that contains Content controls'

Friday, January 14, 2011 5:01 PM by W0ut

I have the same error and the extra HTML added to my Page layouts.

However in my page layouts the <asp:Content> tags all have the correct casing. When I , after deployment, open the page layout with SharePoint Designer all the <asp:Content> tags are in lowercase.

Seems that during the deploy / publishing process the casing gets altered.

Any ideas?

# re: Page Layout Error: 'Only Content controls are allowed directly in a content page that contains Content controls'

Friday, April 22, 2011 9:18 PM by Tom

Everything in a page with <asp:Content></asp:Content> tags has to stay within the tags.  Better to not use them and use standard

*%@ Assembly reference stuff @%*

*%@ Namespace stuff @%*

*html**head**/head**body**/body**/html* tags instead (put in the less than and greater than symbols in for "*", as appropriate), if you can get away with it (outside of SharePoint - Otherwise, can only use Content fields).    Any scripts to be run on the server would go in code-behind.

# re: Page Layout Error: 'Only Content controls are allowed directly in a content page that contains Content controls'

Thursday, July 07, 2011 6:45 PM by Praveen Chandran

I had error in the aspx page itself.

Means, previously the end tag of <asp:Content>> is like this. '>' was added accidently.

I removed that ,then it worked.

# re: Page Layout Error: 'Only Content controls are allowed directly in a content page that contains Content controls'

Monday, October 10, 2011 1:21 AM by tatabánya nyelviskola

strange, but have with similar problam - but only on ONE machine. My bad that this is the build server :/

so everything works fine on the developer machines but the build broke on the ci server with this issue.

We are working with ASP.NET MVC 1.0. Any idea?

thank you

Leave a Comment

(required) 
(required) 
(optional)
(required) 
Please add 3 and 8 and type the answer here: