How to use the site's masterpage from a _layout SharePoint page?

♀尐吖头ヾ 提交于 2019-12-05 14:39:24

Try this:

Leave the MasterPageFile declaration at it's default (~/_layouts/simple.master) and override OnPreInit in your custom code.

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

    this.MasterPageFile = SPContext.Current.Web.MasterUrl;
}

SharePoint requires _layouts pages to be declared with ~/_layouts/application.master. The OnPreInit technique can then be used to change the master at runtime.

An HttpModule can be used to change the master on all application pages: How to customise the SharePoint application.master file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!