“Only Content controls are allowed directly in a content page that contains Content controls”

October 02, 2008

Yesterday a misleading error happened. A custom layout was deployed using Features and WSP solution packages. Everything went well, but when browsing to a page using this new layout, this message appeared:

Only Content controls are allowed directly in a content page that contains Content controls.

image

Furthermore, SharePoint inserted this funny-looking content after our Content element:

> <!--\[if gte mso 9\]><xml>  
> <mso:CustomDocumentProperties>  
> <mso:ContentType msdt:dt="string">Page Layout</mso:ContentType> 
> 
>   

I started googling and I found a blog post by Rich Finn that in essence has the same problem.

CAUSE

Apparently, when a unknown or misspelled tag is found in page layout, SharePoint adds the content type information in a XML fragment, between the <asp:Content&gt; tags. However, in ASP.NET no additional tags are allowed as first-level children, beside Content. In our case we had one <asp:content> tag, which was misspelled.

SOLUTION

Ensure that the <asp:Content> tags are properly capitalized. SharePoint seems to freak out when <asp:content> tag is found.


Profile picture

Written by Edin Kapić Insatiably curious code-writing tinkerer. Geek father. Aviation enthusiast. Cuisine journeyman. Follow me on Twitter