How to create a web page with a web part enabled in an isolated solution

I know that you can create a wiki page in a sandbox solution:

SPUtility.CreateNewWikiPage(list, "{mysiteurl}/CodeGeneratedPage.aspx");

But how can I (if possible) create a webpage page with webpart enabled in my document library? Because everything I can find (like this ) works only in farming solutions. Is there any workaround?

Note. I post this question here because there are more people here.than on the Sharepoint site.

+3
source share
1 answer

Good find. You cannot use it SPLimitedWebPartManagerin isolated code, and therefore, you cannot use it for placing web pages on pages.

Web- - (.. XML), - elements.xml:

  <AllUsersWebPart WebPartZoneID="MainWebPartZone" WebPartOrder="1">
    <![CDATA[
      <webParts>
        <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
          <metaData>
            <type name="MyComp.WebParts.SampleWebPart, MyComp.WebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5" />
            <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
          </metaData>
          <data>
            <properties>
              <property name="Title" type="string">Sample WebPart</property>
            </properties>
          </data>
        </webPart>
      </webParts>
    ]]>       
  </AllUsersWebPart>

:


:

+2

All Articles