2

A specific custom web part is being instantiated twice on a certain page layout, even if it’s only declared once on the page layout.

Declaration like this:

    <%@ Register tagprefix="MyQuickLinks" namespace="Client.Intranet.MyLinksWebPart.MyLinks" assembly="Client.Intranet.MyLinksWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxx" %>

    <WebPartPages:webpartzone runat="server" Title="Web Part Content" ID="WebPartContent">
        <ZoneTemplate>
            <MyQuickLinks:MyLinks ID="MyLinks" Title = "My quicklinks" runat="server"/>
        </ZoneTemplate>
        </WebPartPages:webpartzone>

Creating a new page based on page layout shows web part is rendered/displayed twice.

HTML getting rendered like this--

The first one always:

    <DIV id="WebPartctl00_m_MyLinks" class="ms-WPBody noindex ms-wpContentDivSpace" allowDelete="false" width="100%" HasPers="false" WebPartID="00000000-0000-0000-0000-000000000000" allowExport="false">

*web part ID being all zeroes is strange, cause unknown

The second one always:

    <DIV id="WebPartctl00_m_g_e825e9c9_f070_4ea3_8231_dfda8fbe90a6" class="ms-WPBody noindex ms-wpContentDivSpace" allowDelete="false" width="100%" HasPers="false" WebPartID="657a284d-7048-4713-b792-7a792fe507ad" allowExport="false">

On Edit mode, the first web part cannot be removed and does not show in ‘Open page in web part maintenance’ mode, as if it were not contained in a web part zone

The second one, can be removed like any normal web part

Can no longer add a new web part of the same type to the same page.

Other page layouts that have the exact same web part declaration do not see this issue, and web parts are instantiated only once, and are able to add the same type of web part to the same page several times without error

This is a new SP2010 built from clean/vanilla stand-alone VM.

Please help

2 Answers 2

1

Webparts added to a pagelayout's aspx file are basically rendered as controls. So it can;t be edited or removed etc.

You need to add it using an AllUsersWebPart element in the feature you use to deploy the pagelayout.

4
  • Thanks, that makes sense. I've removed the ID= property of the MyQuickLinks:MyLinks tag (for concurrency issue acc. to williamvanstrien.blogspot.com/2010/01/…) and managed to get rid of the WebPartID="00000000-0000-0000-0000-000000000000"...but still 2 instances are showing up
    – zee
    Commented Jun 27, 2011 at 2:19
  • I'm trying to deploy the web part using AllUsersWebPart now, but keep getting "Cannot recognize the XML namespace of this Web Part" error when opening the page layout after deployment. I got the CDATA from exporting the custom web part itself, so not sure what's wrong there..
    – zee
    Commented Jun 27, 2011 at 4:15
  • rolandoldengarm.wordpress.com/2011/03/02/… This fixed the 'XML namespace' issue. The whole thing works now--definitely must use AllUsersWebPart for instantiating web parts into page layouts.
    – zee
    Commented Jun 28, 2011 at 3:12
  • That's my colleague, whahaha!
    – Colin
    Commented Jun 28, 2011 at 9:07
0

Delete property item from Elements.xml

<File Path="Default.aspx" Url="Default.aspx" Type="GhostableInLibrary" ReplaceContent="TRUE">
  <!--<Property Name="Title" Value="Default"></Property>-->
</File>

This helped me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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