Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Following is the code in my page layout.

<WebPartPages:WebPartZone id="page_detail" runat="server" title="Page Detail" PartChromeType="None"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>

Is it possible to add a default web part here so when the page loads, that web part is already there rather than user has to cick on "Add a web part" link?

I would like to add Content Editor web part here.

share|improve this question

1 Answer 1

Try to add this code to the page. This works for me in a master page but I didn't try in a page layout

<asp:WebPartManager ID="WebPartManager1" runat="server"/>
    <asp:WebPartZone ID="WebPartZone1" runat="server">
        <ZoneTemplate>
            <WebPartPages:ContentEditorWebPart ID="ContentEditorWebPart1" runat="server" __MarkupType="xmlmarkup" WebPart="true" __WebPartId="{put your guid here}" >
               <WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2">
                  <Title>Content Editor</Title>
          <FrameType>None</FrameType>
          <Description>Allows authors to enter rich text content.</Description>
          <IsIncluded>true</IsIncluded>
          <FrameState>Normal</FrameState>
          <AllowRemove>true</AllowRemove>
          <AllowZoneChange>true</AllowZoneChange>
          <AllowMinimize>true</AllowMinimize>
          <AllowConnect>true</AllowConnect>
          <AllowEdit>true</AllowEdit>
          <AllowHide>true</AllowHide>
          <IsVisible>true</IsVisible>
          <DetailLink />
          <HelpLink />
          <HelpMode>Modeless</HelpMode>
          <Dir>Default</Dir>
          <PartImageSmall />
          <MissingAssembly>Cannot import this Web Part.</MissingAssembly>
          <PartImageLarge>/_layouts/15/images/mscontl.gif</PartImageLarge>
          <IsIncludedFilter />
          <Assembly>Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
          <TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>
          <ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
          <Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">PUT YOUR CONTENT HERE</Content>
          <PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
              </WebPart>
            </WebPartPages>
        </ZoneTemplate>
    </asp:WebPartZone>

Good Luck

share|improve this answer
    
Not working in page layout. It is showing error "The control type 'System.Web.UI.WebControls.WebParts.WebPartManager' is not allowed on this page." –  Frank Martin Aug 5 '13 at 6:36

Your Answer

 
discard

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.