开发者

Dynamic Master Pages in SharePoint 2007 Publishing sites

I’m trying to do dynamic switching of the master page in SharePoint 2007 publishing site.

I’m following this example which uses a HTTP Module

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 EventH开发者_开发问答andler(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 (e.g. BlueBand.master) the page_PreInit procedure is never called - it is still being registered with the event handler though.


oh yes!

http://webcache.googleusercontent.com/search?q=cache:SVA_9XSp1lwJ:www.pings.dk/blog/archive/tags/Master%2520page/default.aspx+spcontext.current.web.custommasterurl&hl=en&gl=uk&strip=1

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜