zoukankan      html  css  js  c++  java
  • 正确的修改自定义母版页方式

      网上大部分文章都是用sharepoint designer 去修改母版页,这种方式虽然能达到目的,但你的母版页存在数据库(spd设计的母版页没有保存在服务器磁盘),每次都要用spd去打开修改,不便于维护迁移,如果交接工作下一个接手人不知道这个,那就更加麻烦了。

      正确的方式是在VS中新建一个母版页,修改前端,然后在VS的sharepoint项目的Feature使用事件去修改。

      意思是每当这个Feature激活时,我们就将该SPWeb的母版页修改成我们自定义的母版页。

      代码如下:

      

    if (pageNo.Equals("1"))
                 {
                     page.MasterPageFile = "~masterurl/custom.master";
                     if (SPContext.Current != null)
                     {
                         SPContext.Current.Web.CustomMasterUrl = 
    				"/_catalogs/masterpage/custom1.master";
                     }
                 }
                 else if (pageNo.Equals("2"))
                 {
                     page.MasterPageFile = "~masterurl/custom.master";
                     if (SPContext.Current != null)
                     {
                         SPContext.Current.Web.CustomMasterUrl = 
    				"/_catalogs/masterpage/custom2.master";
                     }
                 }
                 else
                 {
                     page.MasterPageFile = "~masterurl/default.master";
                     if (SPContext.Current != null)
                     {
                         SPContext.Current.Web.MasterUrl = 
    				"/_catalogs/masterpage/default.master";
                     }
                 }
    

      这里需要注意的是Customer母版页和Master母版页。

      Customer母版页供用户查看,Master母版页是系统管理员进入系统页面使用的母版页。

      

  • 相关阅读:
    简单破解.net(C#)程序
    URL和URI
    Java JDK安装和配置(Windows)
    函数式编程语言
    Http
    drf 序列化获取商品分类数据
    npm install 安装依赖报错
    27-----BBS论坛
    26-----BBS论坛
    25-----BBS论坛
  • 原文地址:https://www.cnblogs.com/olay/p/6800839.html
Copyright © 2011-2022 走看看