Question

SharePoint 2007 Enterprise, SP2.

I am getting a strange error (found in the ULS logs, Google reports no hits on the message itself) when trying to upload a page with a webpart preloaded in a zone:

An unexpected error has been encountered in this Web Part. Error: Unable to parse markup correctly. It is likely that the markup should be in Visual Studio Attribute format, but the given markup is in XML Format., DesignText: <VPCQWP:ComponentLandingCQWP runat="server" id="CL_CQWP" />

This webpart derives from the ContentByQueryWebPart class, and sets a number of web-context sensitive properties.

This is the whole of the WebPartZone, and yes - the TagPrefix is registered properly at the top of the page:

<WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly" ID="TopLeft" Title="Top Left">
  <ZoneTemplate>
    <VPCQWP:ComponentLandingCQWP runat="server" id="CL_CQWP"></VPCQWP:ComponentLandingCQWP>
  </ZoneTemplate>
</WebPartPages:WebPartZone>

The crazy part is if I clear this web part out from the zone, upload the page, and then add the web part back in thru the web UI, it works, no problem. What am I missing here?

Was it helpful?

Solution

When you add the web part directly to the page layout, the page get parsed by the ASP.NET engine as part of the page. This will often give you a different behaviour than provisioning through a feature or ONET.XML (i saw this myself trying to use uint instead of int here).

Im not sure if its a normal CQWP you got there, or if you rolled your own, but make sure you set all valid properties on the control, as you would if you had configured the webpart xml.

To check what properties need to be there, use SharePoint Designer to add the web part on the Page Layout (OBS: just copy the control in code view, and undo changes to Page Layout so you dont unghost/customize your page layout)

Below is an example of default settings when dragging a CQWP into a PL using SPD:

<PublishingWebControls:ContentByQueryWebPart 
    runat="server" 
    NoDefaultStyle="" 
    ZoneID="" 
    FrameType="TitleBarOnly" 
    Dir="Default" 
    UseSQLDataSourcePaging="True" 
    AllowConnect="True" 
    Title="Content Query Web Part" 
    SuppressWebPartChrome="False" 
    ViewContentTypeId="" 
    MissingAssembly="Cannot import this Web Part." 
    FrameState="Normal" 
    ID="ContentByQueryWebPart1" 
    AllowRemove="True" 
    AllowHide="True" 
    AllowEdit="True" 
    ShowWithSampleData="False" 
    IsIncluded="True" 
    PartImageLarge="" 
    PartOrder="1" 
    PartImageSmall="" 
    AllowMinimize="True" 
    ConnectionID="00000000-0000-0000-0000-000000000000" 
    ExportMode="All" 
    IsIncludedFilter="" 
    GroupStyle="DefaultHeader" 
    HelpLink="" 
    SortByDirection="Desc" 
    IsVisible="True" 
    SortBy="{8c06beca-0777-48f7-91c7-6da68bc07b69}" 
    DataSourceID="" 
    AllowZoneChange="True" 
    HelpMode="Modeless" 
    ExportControlledProperties="True" 
    AdditionalFilterFields="" 
    AdditionalGroupAndSortFields="" 
    DetailLink="" 
    ItemStyle="Default" 
    Description="Use to display a dynamic view of content from your site on a web page" 
    ChromeType="TitleOnly" 
    PageSize="-1" 
    __MarkupType="vsattributemarkup" 
    __WebPartId="{b9de16fc-23b5-4d39-aaf7-3e42e8389548}" 
    WebPart="true" 
    Height="" 
    Width="">
    <SampleData>
        <dsQueryResponse>
                    <Rows>
                        <Row Title="Item 1" LinkUrl="http://Item1" Group="Group Header" __begincolumn="True" __begingroup="True" />
                        <Row Title="Item 2" LinkUrl="http://Item2" __begincolumn="False" __begingroup="False" />
                        <Row Title="Item 3" LinkUrl="http://Item3" __begincolumn="False" __begingroup="False" />
                    </Rows>
                </dsQueryResponse></SampleData>
    <DataFields>
    </DataFields>
    <Xsl>
    <xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:cmswrt="http://schemas.microsoft.com/WebPart/v3/Publishing/runtime" exclude-result-prefixes="xsl cmswrt x" > <xsl:import href="/Style Library/XSL Style Sheets/Header.xsl" /> <xsl:import href="/Style Library/XSL Style Sheets/ItemStyle.xsl" /> <xsl:import href="/Style Library/XSL Style Sheets/ContentQueryMain.xsl" /> </xsl:stylesheet></Xsl>
</PublishingWebControls:ContentByQueryWebPart>

hth Anders Rask

OTHER TIPS

I have to agree with Anders, if it is a CQWP that you have subclasses, you need either to specify a lot more properties or set them in your web part (in onload/createchildcontrols for instance). For example what properties have you set within the .webpart file? Adding the web part using the web interface is not the same as specifing the control in a web part zone template. When you are adding it via the webinterface then the web part control description file (.webpart) is used to get the default values of the web part.

/WW

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top