4

I am provisioning a webpart to a webpart page in sandboxed solution. here is the module's element.xml

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="MyModule" Url="SitePages" Path="MyModule">
    <File Url="Main.aspx"
         Name="Home.aspx"
         Type="Ghostable" >

      <AllUsersWebPart ID="g_21f871c5_3575_4182_a7e2_64f682877071" WebPartOrder="1" WebPartZoneID="Top">
        <![CDATA[
          <webParts>
            <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
              <metaData>
                <type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
                <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
              </metaData>
              <data>
                <properties>
                  <property name="ListUrl" type="string">Lists/Announcements</property>
                  <property name="ExportMode" type="exportmode">All</property>
                  <property name="AllowZoneChange" type="bool">True</property>
                  <property name="ExportMode" type="exportmode">All</property>
                  <property name="HelpUrl" type="string" />
                  <property name="Hidden" type="bool">False</property>
                  <property name="TitleUrl" type="string" />
                  <property name="Description" type="string"></property>
                  <property name="AllowHide" type="bool">True</property>
                  <property name="AllowMinimize" type="bool">True</property>
                  <property name="ChromeType" type="chrometype">Default</property>
                  <property name="AllowConnect" type="bool">True</property>
                  <property name="Width" type="unit" />
                  <property name="Height" type="unit" />
                  <property name="HelpMode" type="helpmode">Navigate</property>
                  <property name="CatalogIconImageUrl" type="string" />
                  <property name="AllowEdit" type="bool">True</property>
                  <property name="TitleIconImageUrl" type="string" />
                  <property name="Direction" type="direction">NotSet</property>
                  <property name="AllowClose" type="bool">True</property>
                  <property name="ChromeState" type="chromestate">Normal</property>
                </properties>
              </data>
            </webPart>
          </webParts>
        ]]>
      </AllUsersWebPart>
</File>
  </Module>
</Elements>

I am able to see the webpart in the page but when I edit the page the web part is not visible, also i am unable to edit the webpart from the page. The webpart is visible in webpart maintenance page.

Am i missing something here which is causing this behavior.

Help in any form is appreciable.

  • Are you sure that the WebPart zone is correct? make sure it does exist with that name in the page. What you describe sounds like a web part not provisioned in a Web part zone. – Marius Constantinescu - MVP Sep 29 '13 at 0:51
  • The webpart zone(Top) was incorrect, the existing zone names in the page were, Header, RightColumn, LeftColumn, MiddleColumn and Footer. I have tried all but none of them seems to working – user4205 Sep 30 '13 at 7:41
  • It seems SitePage/Home.aspx is a wiki page and not a webpart page – user4205 Sep 30 '13 at 9:23
  • Also note that you have the ExportMode property defined twice. – Cameron Verhelst Mar 3 '14 at 12:13
1

As mentioned in the comment to the question SitePage/Home.aspx was an wiki page created by sharepoint once you activate the WikiHomePage feature(By default activated on team site). Hence for my requirement what I did is

1) Created a webpart page(with Header,Right Column, Body layout template) using the UI in the SitePsges Library, without any data.

2) Opened the site in sharepoint designer, and opened the above created page.

3) Copied the code.

4) Added a new Module(Add new Item -> Module), Deleted the Sample.txt and added an aspx page.

5) Replaced the content with the above copied code(Step 3)

Now the module looks like this

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="WikiHomePageModule" Url="SitePages">
    <File Path="WikiHomePageModule\Main.aspx" Url="Main.aspx" Type="GhostableInLibrary" ReplaceContent="TRUE">
      <Property Name="ContentTypeId" Value="0x01010800FEC87ED74A596F44BB470458CB22030A" />
      <Property Name="FileLeafRef" Value="Main.aspx" />
      <Property Name="ContentType" Value="Wiki Page" />
<AllUsersWebPart ID="g_21f871c5_3575_4182_a7e2_64f682877071" WebPartOrder="1" WebPartZoneID="Body">
        <![CDATA[
          <webParts>
            <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
              <metaData>
                <type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
                <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
              </metaData>
              <data>
                <properties>
                  <property name="ListUrl" type="string">Lists/Announcements</property>
                  <property name="ExportMode" type="exportmode">All</property>
                  <property name="AllowZoneChange" type="bool">True</property>
                  <property name="ExportMode" type="exportmode">All</property>
                  <property name="HelpUrl" type="string" />
                  <property name="Hidden" type="bool">False</property>
                  <property name="TitleUrl" type="string" />
                  <property name="Description" type="string"></property>
                  <property name="AllowHide" type="bool">True</property>
                  <property name="AllowMinimize" type="bool">True</property>
                  <property name="ChromeType" type="chrometype">Default</property>
                  <property name="AllowConnect" type="bool">True</property>
                  <property name="Width" type="unit" />
                  <property name="Height" type="unit" />
                  <property name="HelpMode" type="helpmode">Navigate</property>
                  <property name="CatalogIconImageUrl" type="string" />
                  <property name="AllowEdit" type="bool">True</property>
                  <property name="TitleIconImageUrl" type="string" />
                  <property name="Direction" type="direction">NotSet</property>
                  <property name="AllowClose" type="bool">True</property>
                  <property name="ChromeState" type="chromestate">Normal</property>
                </properties>
              </data>
            </webPart>
          </webParts>
        ]]>
      </AllUsersWebPart>
</File>
  </Module>
</Elements>

Deployed the Solution what it did is, created a new page(Main.aspx) in the SitePages library along with the default Home.aspx. Now My requirement was to set the custom page as home page for that I followed this Blog

Three ways to change Home page

I used the Second approach, the property bag one. As i need to deploy the saolution as an sandboxed solution to office 365

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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