很简单,只要在页面的OnPreInit方法里动态设置MasterPageFile 属性为当前站点的MasterUrl即可:
protected
override
void
OnPreInit(EventArgs e)
{
base .OnPreInit(e);
if (SPContext.Current != null )
Page.MasterPageFile = SPContext.Current.Web.MasterUrl;
}
{
base .OnPreInit(e);
if (SPContext.Current != null )
Page.MasterPageFile = SPContext.Current.Web.MasterUrl;
}
在aspx里就要这么写:
protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
this .MasterPageFile = base.Web.MasterUrl;
}