locked
PageLayouts - adding web parts

    Question

  • I have a page layout with three web part zones.

    Each of these web part zones has an embedded web part within it.

    The page loads and renders fine and and all of the web parts populate as they're supposed to.

     

    However, when I attempt to add a new web part (even out-of-the-box web parts) to one of these zones, I get an error telling me that the "... Web Part was deleted by another user or is invalid."

    This only happens when I attempt to add web parts to zones that have existing web parts embedded in them via the page layout.

     

    I've also attempted to add the web parts in the same manner as Andrew Connel does here, but I then get the following exception:

     

    "No parameterless constructor defined for this object" which, based on my brief research is due to the fact that a CurrentItem attribute is added to the web part definition at runtime.

     

    Does this sound familiar to anyone and if so can you please offer any advice so I'll be able to embed web parts into my page layouts as well add additional web parts to those same zones?

    Tuesday, April 01, 2008 2:53 PM

Answers

  • Hi George, thanks for responding.

    I am using a custom page layout based on a custom content type I've created.

     

    For the time being I've added an additional empty web part zone above each web part zone containing an embedded web part. I then set the "AllowCustomization" property of the original zones to False so the users are not able to attempt to add new web parts. This is working fine, but I would really like to know if a solution to the original issue exists.

    Tuesday, April 01, 2008 8:28 PM

All replies

  • I ran into something similar, but found out it was due to an issue with the page layout itself.  Are you using a custom page layout?
    Tuesday, April 01, 2008 7:13 PM
  • Hi George, thanks for responding.

    I am using a custom page layout based on a custom content type I've created.

     

    For the time being I've added an additional empty web part zone above each web part zone containing an embedded web part. I then set the "AllowCustomization" property of the original zones to False so the users are not able to attempt to add new web parts. This is working fine, but I would really like to know if a solution to the original issue exists.

    Tuesday, April 01, 2008 8:28 PM
  • I've seen this error when developing custom webparts and trying to insert them into a pagelayout so they would be provisioned automatically on a new page using the pagelayout. The solution was that I didn't copy the webpart information correctly in the AllUsersWebPart section of my elements.xml file. The easiest is to browse to your webpart gallery (/_catalogs/wp/Forms/AllItems.aspx) and edit the webpart you wish to place on the page. You'll have an option to view the XML declaration of the webpart definition. Copy that entirely but without the first line containing the XML specification and paste that within the AllUsersWebPart CDATA section.

    For example, an elements.xml might look like:

     

    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
     <Module Name="PageLayouts" List="116" Url="_catalogs/masterpage">
      <File Path="PageLayouts\SomeCustomPage.aspx" Url="SomeCustomPage.aspx" IgnoreIfAlreadyExists="TRUE" Type="GhostableInLibrary">
       <Property Name="Title" Value="Custom page" />
       <Property Name="MasterPageDescription" Value="Custom page for this webpart provisioning sample" />
       <Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" />
       <Property Name="PublishingPreviewImage" Value="~SiteCollection/_catalogs/masterpage/Preview Images/PreviewImage.png, ~SiteCollection/_catalogs/masterpage/Preview Images/PreviewImage.png" />
       <Property Name="PublishingAssociatedContentType" Value=";#Custom page;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D;#" />
       <AllUsersWebPart WebPartZoneID="HeaderWebPartZone" WebPartOrder="0">
        <![CDATA[
         <webParts>
         <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
          <metaData>
           <type name="Koen.SharePoint2010.WebParts.SampleWebPart, Koen.SharePoint2010.WebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=41cc869254a872221" />
           <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
          </metaData>
          <data>
           <properties>
            <property name="Title" type="string">Custom webpart</property>
            <property name="Description" type="string">Sample webpartr</property>
            <property name="ChromeType" type="chrometype">None</property>
            <property name="CatalogIconImageUrl" type="string">/SiteCollectionImages/BrandingImages/KZLogo16.gif</property>
           </properties>
          </data>
         </webPart>
        </webParts>
        ]]>
       </AllUsersWebPart>
      </File>
     </Module>
    </Elements>
    
    

     

    • Edited by Koen Zomers Monday, March 14, 2011 10:28 PM Formatted the XML for better readability
    Monday, March 14, 2011 10:27 PM