Вопрос

I am looking for a way to deploy a custom page to sharepoint.

Currently I was able to do it via sharepoint, by adding an aspx page to the project. This added an aspx pages to layouts and it deployed it to sharepoint.

The page page did work, but I was unable to make it the welcome page. It seems that the welcome page can be only a page that resides in "SitePages" directory.

So how could I deploy to SitePages a page via visual studio?

I am using Sharepoint 2013 with visual studio 2012.

Это было полезно?

Решение

The page can be deployed to Site Pages library using module. Sample module file code:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="Webpartpage" Url="SitePages">
    <File Path="Webpartpage\MyPage.aspx" Url="MyPage.aspx"  
          Type="GhostableInLibrary" IgnoreIfAlreadyExists="FALSE">
      <AllUsersWebPart WebPartOrder ="0" WebPartZoneID ="wpzMyZone">
        <![CDATA[ 
          <webParts>
            <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
              <metaData>
                <type name="WebpartPages.MyWebpart.MyWebpart, WebpartPages, 
                Version=1.0.0.0, Culture=neutral, PublicKeyToken=132122a1200767d5" />
                <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
              </metaData>
              <data>
                <properties>
                  <property name="Title" type="string">MyWebpart</property>
                  <property name="Description" type="string">Mywebpart</property>

                </properties>
              </data>
            </webPart>
          </webParts>
        ]]>
      </AllUsersWebPart>
    </File>
  </Module>
</Elements>

Check Deploy webpart page using module for more information

Лицензировано под: CC-BY-SA с атрибуция
Не связан с sharepoint.stackexchange
scroll top