zoukankan      html  css  js  c++  java
  • Set the Welcome Page in SharePoint through Code

    默认情况下,SharePoint使用sitepagesHome.aspx作为welcome page,但有时我们需要使用定制页面作为welcome page。在SharePoint中, 设置Welcome Page的方式跟Web是否Publish有关,即SharePoint Server Publishing Infrastructure是否启动。

    1. SharePoint Server Publishing Infrastructure这个feature没启动时的设置方式:

    SPFolder rootFolder = web.RootFolder;
    rootFolder.WelcomePage = "SitePages/customHomePage.aspx";
    rootFolder.Update();
     
    2.如果SharePoint Server Publishing Infrastructure已经启动,则使用一下方式进行设置,否则虽然后台代码能够设置成功,但是页面还是会报错误:The DataSourceID of 'TopNavigationMenu' must be the ID of a control of type IHierarchicalDataSource
    
      if (PublishingWeb.IsPublishingWeb(web))
       {
                        PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
                        SPFile welcomeFile = web.GetFile(squarePath);
    
                        publishingWeb.DefaultPage = welcomeFile;
                        publishingWeb.Update();
                    }
                   
  • 相关阅读:
    洛谷 P5043 树的同构 题解
    CF 1178E Archaeology 题解
    UVA 1642 MagicalGCD 题解
    洛谷 P3919 可持久化线段树 题解
    SPOJ 4003 Phone List 题解
    OI/ACM最全卡常大招
    洛谷 P3368 树状数组 题解
    逆序对
    洛谷 U78696 图书馆馆长的考验 题解
    原创 疲劳炉石传说
  • 原文地址:https://www.cnblogs.com/snailJuan/p/3361304.html
Copyright © 2011-2022 走看看