Sign up ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have created some page layouts with web part zones in visual studio and they work fine, however, I don't want to have to manually add web parts in the zones each time a new page is created using that layout.

I have in my elements file for the layouts:

<File Path="Masterpage\Department.aspx" Url="Department.aspx" Type="GhostableInLibrary">
    <Property Name="Title" Value="Department Layout" />
    <Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" />
    <Property Name="PublishingPreviewImage" Value="~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/PreviewImage/PageLayoutIcon.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/PreviewImage/PageLayoutIcon.png" />
    <Property Name="PublishingAssociatedContentType" Value=";#$Resources:cmscore,Department Content Type;#0x01010007FF3E057FA8AB4AA42FCB67B453FFC100E214EEE741181F4E9F7ACC43278EE81100048d8f4ef5834fa2bcfdb8b0fac9a9c3;#"/>
    <AllUsersWebPart WebPartZoneID="BottomLeft" WebPartOrder="1">
        <?xml version="1.0" encoding="utf-8"?>
          <webPart xmlns="">
              <type name="Microsoft.SharePoint.WebPartPages.ContentEditorWebPart, Microsoft.SharePoint" />
                <property name="Title" type="string">test</property>
                <property name="Description" type="string">test</property>

and on the layout the zone:

<WebPartPages:WebPartZone runat="server" Title="loc:Bottom Left" ID="BottomLeft" FrameType="None"></WebPartPages:WebPartZone>

but when I deploy this and add a new page using the layout the zone is empty, no web part there so what am I missing here?

Thanks in advance.

Edit: so when I delete the layout and redeploy and have a look at it with SPD the zone gets populated but it doesn't look right and when I go to a page and try to use that layout I get an error:

in the web part zone:

<webParts __WebPartId="{D25AA5E4-EEA1-4709-830F-9DCE18A11E18}" __MarkupType="xmlmarkup" WebPart="true">
          <webPart xmlns="">
               <type name="Microsoft.SharePoint.WebPartPages.ContentEditorWebPart, Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
              <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
             </metaData><data><properties><property name="Title" type="string">test</property> <property name="Description" type="string">test</property> </properties></data></webPart></webParts>


[MissingMethodException: No parameterless constructor defined for this object.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) +146
   System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) +298
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +79
   Microsoft.SharePoint.WebPartPages.SPWebPartReflectionHelper.GetDefaultControl(Type controlType) +140
   Microsoft.SharePoint.WebPartPages.BinaryWebPartSerializer.GetDefaultControl() +38
   Microsoft.SharePoint.WebPartPages.BinaryWebPartSerializer.Serialize(PersonalizationScope scope) +832
   Microsoft.SharePoint.WebPartPages.BinaryWebPartSerializer.get_Links() +46
   Microsoft.SharePoint.WebPartPages.SPWebPartManager.AddWebPartToStore(WebPart webPart, Int32 viewId, String viewGuid) +532
   Microsoft.SharePoint.WebPartPages.SPWebPartManager.AddWebPartInternal(SPSupersetWebPart superset, Boolean throwIfLocked) +233
   Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager.AddWebPartInternal(WebPart webPart, String zoneId, Int32 zoneIndex, Boolean throwIfLocked) +116
   Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager.AddWebPart(WebPart webPart, String zoneId, Int32 zoneIndex) +37
   Microsoft.SharePoint.Publishing.PublishingPage.CopyAllWebParts(String destinationPageUrlServerRelative, SPWeb destinationPageWeb, String sourcePageUrlServerRelative, SPWeb sourcePageWeb, Boolean shouldOverwriteDestinationWebParts) +600
   Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.PageLayoutAction.changePageLayout(String newPageLayoutUrl) +480
   Microsoft.SharePoint.Publishing.WebControls.EditingMenuActions.PageLayoutAction.RaisePostBackEvent(String eventArgument) +135
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981
share|improve this question

2 Answers 2

up vote 1 down vote accepted

Try this:

            <![CDATA[<WebPart xmlns:xsi="" xmlns:xsd="" xmlns="">
  <Title>Content Editor Testing</Title>
  <Description>Allows authors to enter rich text content.</Description>
  <Height />
  <Width />
  <DetailLink />
  <HelpLink />
  <PartImageSmall />
  <MissingAssembly>Cannot import this Web Part.</MissingAssembly>
  <IsIncludedFilter />
  <Assembly>Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
  <ContentLink xmlns="" />
  <Content xmlns="" />
  <PartStorage xmlns="" />
share|improve this answer
same result unfortunately, no web part is added to the layout – john Mar 23 '12 at 5:20
Can you try deleting the existing page layout from the gallery and re-activate your feature. Also after you create a new page, append ?contents=1 to the url to see list of webparts on the page. – sssreddy Mar 23 '12 at 15:42
Hi sssreddy, I updated my question a bit. – john Mar 26 '12 at 6:10
Was able to deploy page layout using above xml. see edited ans. – sssreddy Mar 26 '12 at 17:27
I want to do something similar to the above, except I would like my ContentEditorWebPart to deploy with some HTML already in it. I was able to arrive at the above XML snippet on my own by exporting to a .dwp file. The <Content ...> node in my scenario has it's own embedded CDATA section where my HTML is seeded. When I put together my Visual Studio module file, it looks like I cannot nest a CDATA inside the larger CDATA section. Am I right? – bkwdesign Nov 2 '12 at 15:32

Do you have any uint type property in your web part? Please check that. If any of uint type property exist in your webpart code, then change the type from uint to int.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.