P
paul1664
Hi,
I'm currently loading my masterpage from a file via an httpmodule.
How can I modify this code to load the masterpage from a database? Is
the only way to save the file to a temp file first and load via
page.MasterPageFile?
Thanks,
Paul.
using System;
using System.Web;
using System.Web.UI;
public class MasterPageModule : IHttpModule
{
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)
{
Page page = sender as Page;
if (page != null)
{
page.MasterPageFile = "~/MasterPage.master";
}
}
public void Dispose()
{
}
}
I'm currently loading my masterpage from a file via an httpmodule.
How can I modify this code to load the masterpage from a database? Is
the only way to save the file to a temp file first and load via
page.MasterPageFile?
Thanks,
Paul.
using System;
using System.Web;
using System.Web.UI;
public class MasterPageModule : IHttpModule
{
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)
{
Page page = sender as Page;
if (page != null)
{
page.MasterPageFile = "~/MasterPage.master";
}
}
public void Dispose()
{
}
}