简体   繁体   English

SharePoint 2007发布网站中的动态母版页

[英]Dynamic Master Pages in SharePoint 2007 Publishing sites

I'm trying to do dynamic switching of the master page in SharePoint 2007 publishing site. 我正在尝试在SharePoint 2007发布网站中动态切换母版页。

I'm following this example which uses a HTTP Module 我正在跟踪这个使用HTTP模块的示例

http://ranaictiu-technicalblog.blogspot.com/2009/10/sharepoint-dynamically-change-master.html http://ranaictiu-technicalblog.blogspot.com/2009/10/sharepoint-dynamically-change-master.html

Here is my code 这是我的代码

public class SwitchMasterPage : IHttpModule
{
    public void Dispose()
    {

    }
    public void Init(HttpApplication context)
    {
        context.PreRequestHandlerExecute += new EventHandler(context_PreRequestHandlerExecute);
    }

    void context_PreRequestHandlerExecute(object sender, EventArgs e)
    {
        Page page = HttpContext.Current.CurrentHandler as Page;
        if (page != null)
        {
            page.PreInit += new EventHandler(page_PreInit);
        }
    }

    void page_PreInit(object sender, EventArgs e)
    {
        Logger.Verbose("SwitchMasterPage:page_PreInit", "I'm in the preInit event.");
    }
}

Everything is working fine when the current page type is an Application Page, however when the page type is a Publishing page (eg BlueBand.master) the page_PreInit procedure is never called - it is still being registered with the event handler though. 当前页面类型是应用程序页面时,一切工作正常,但是,当页面类型是发布页面(例如BlueBand.master)时,page_PreInit过程从不调用-尽管它仍在事件处理程序中注册。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM