Code blocks are not allowed in this file - SharePoint error with custom page layout

by James 4/3/2008 7:41:00 PM

Yes, I do have C# code in custom page layout. And you probably thinking it is just another post about putting "<PageParserPath />" tag inside web.config.

But the answer is No. I managed to pin down the problem without having <PageParserPath /> tag. Well.. at least in my case.

Problem -

I got this error when I was creating a new publishing page, base on the custom page layout I have deployed to SharePoint site.

James Tsai .Net Blog - C# ASP.NET SharePoint VSTO - Page Layout code block error

Solution

The reason I know <PageParserParth /> is not the answer to this problem is that, only two out of seven page layouts I deployed having this issue.

So I opened those "broken" page layouts from the site in SharePoint designer and found following code got injected to the bottom of my custom page layouts

<html xmlns:mso="urn:schemas-microsoft-com:office:office"
xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"><head> <META name="WebPartPageExpansion" content="full"> <!--[if gte mso 9]><xml> <mso:CustomDocumentProperties> <mso:PublishingPreviewImage msdt:dt="string"></mso:PublishingPreviewImage> <mso:ContentType msdt:dt="string">Page Layout</mso:ContentType> <mso:MasterPageDescription msdt:dt="string"></mso:MasterPageDescription> <mso:PublishingAssociatedVariations msdt:dt="string"> </mso:PublishingAssociatedVariations> <mso:PublishingHidden msdt:dt="string">0</mso:PublishingHidden> <mso:PublishingAssociatedContentType msdt:dt="string"> ;#Agenda item;#0x010100C568DB52D...;#</mso:PublishingAssociatedContentType> </mso:CustomDocumentProperties> </xml><![endif]--> <title>Dummy Content Type</title></head>

I couldn't figure out how this got into my page layouts . But I am sure that SharePoint treated those "broken" page layouts differently as to other working page layouts.

I compared them side by side, read about PlaceHolderPageTitle is the root of all evil  post. I found in my broken page layouts they all got lower case <asp:content /> tag for PlaceHolderPageTitle place holder. So I changed <asp:content /> to <asp:Content />, and it fixed the problem!

<asp:Content contentplaceholderid="PlaceHolderPageTitle" runat="server"> <SharePointWebControls:FieldValue id="PageTitle"
FieldName="Title" runat="server"/> </asp:Content>

Unlike Waldek's situation in the his post, I do have PlaceHolderPageTitle place holder in my page layouts. So this place holder is case sensitive? (because all my other place holders still use lower case <asp:content /> tag. )

Currently rated 4.3 by 4 people

  • Currently 4.25/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

SharePoint

Comments

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen Adopted by James Tsai

About the author

Name of author James Tsai
.NET / SharePoint Consultant
Columbus, OH

E-mail me Send mail

Calendar

<<  March 2010  >>
MoTuWeThFrSaSu
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234
View posts in large calendar

Certifications

MCPD
MCTS

Recent comments

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

Sign in