Tuesday, April 12, 2011

SharePoint Page layout error: Only Content controls are allowed directly in a content page that contains Content controls

I was working on a Publishing pages for a customer today. I created a new custom page layout using Visual studio and created a new page based on the page layout. Everything worked fine until today morning. Suddenly my publishing page was throwing a error  " Only Content controls are allowed directly in a content page that contains Content controls". and showed some html elements in the error message which is placed outside of the content place holder.

I double checked my page layout. There was no html elements inside it. Everything is placed under the ContentPlaceHolder. Then whats the problem...very strange..

I opened the page in designer. To my surprise, I could see some html markups added to the page. I don't know what has happened after I deployed my page layout.

I went back to my page layout design and after much analysis i could figure out the culprit. Its the case sensitive of contentplaceholder tag.
My code was like this which is actually fine and should work.

<asp:contentplaceholderId="PlaceHolderPageTitle" runat="server"></asp:content)

I changed the 'c' in the contentplaceholder tag to upper case like this

<asp:ContentPlaceholderID="PlaceHolderPageTitle" runat="server"></asp:Content).

Redeployed the solution and it did the trick. It was working fine. So the lower case of the content place holder tag has actually inserted some html markups to my page which in turn has caused me the error.

Hope this helps someone.




1 comment: