• 正确的修改自定义母版页方式


      网上大部分文章都是用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母版页是系统管理员进入系统页面使用的母版页。

      

  • 相关阅读:
    springmvc 注解式开发 处理器方法的返回值
    springmvc 注解式开发 接收请求参数
    【洛谷P1379】八数码难题 状压bfs
    【模板】ST表
    【POJ1741】Tree
    【洛谷P1073】最优贸易
    【POJ3662】Telephone Lines dij + 二分答案
    【模板】spfa
    【洛谷P2384】最短乘积路径
    【bzoj2038】小Z的袜子
  • 原文地址:https://www.cnblogs.com/olay/p/6800839.html
Copyright © 2020-2023  润新知