zoukankan      html  css  js  c++  java
  • 如何使Layouts里的页面应用站点母板页

    今天有个朋友问这个问题,写一下~

    很简单,只要在页面的OnPreInit方法里动态设置MasterPageFile 属性为当前站点的MasterUrl即可: 

    protected override void OnPreInit(EventArgs e)
        {
            
    base.OnPreInit(e);

            
    if (SPContext.Current != null)
                Page.MasterPageFile 
    = SPContext.Current.Web.MasterUrl;
        }

     

    在aspx里就要这么写: 

    <script runat="server">
        
        protected override 
    void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);
            
    this.MasterPageFile = base.Web.MasterUrl;
        } 
        
    </script>

     自己开发的页面如果运行在SharePoint环境下也可这样来实现母板页的统一。

  • 相关阅读:
    springboot 基础
    spring 基础
    spring MVC 基础
    windows shell
    oracle 创建用户和视图并授权
    maven 安装本地依赖
    JAVA ssl 证书
    mybatis 递归
    MyBatis基础
    当年的毕设-cpf (一个简易的协议 fuzzer)
  • 原文地址:https://www.cnblogs.com/jianyi0115/p/1299019.html
Copyright © 2011-2022 走看看