如果网站上有两个主页面。如何设置第二组页面布局以便从第二个母版页而不是网站的默认母版页进行绘制?如何将页面布局设置为不同的母版页?
我看到了MasterPageFile =“”的建议,但是,我收到了一个找不到的文件,虽然路径/文件存在(〜/ _catalogs/masterpage/MyMaster.master)。
其次,纯粹通过SharePoint Designer可以做到这一点吗?
如果网站上有两个主页面。如何设置第二组页面布局以便从第二个母版页而不是网站的默认母版页进行绘制?如何将页面布局设置为不同的母版页?
我看到了MasterPageFile =“”的建议,但是,我收到了一个找不到的文件,虽然路径/文件存在(〜/ _catalogs/masterpage/MyMaster.master)。
其次,纯粹通过SharePoint Designer可以做到这一点吗?
母版页驻留在网站集级别的库中。
所以,你应该修改MasterPageFile
如下属性:
<%@ Page language="C#" MasterPageFile="/_catalogs/masterpage/custom2.master"
,或者使用下面的~
操作:
<%@ Page language="C#" MasterPageFile="~sitecollection/_catalogs/masterpage/custom2.master"
您可以在Page_PreInit
方法中更改主页面。
protected void Page_PreInit(object sender, EventArgs e)
{
this.MasterPageFile = "~/Site1.Master";
}
这会不会在页面布局本身? –
不,这将位于页面文件后面的代码中。 – VDWWD
谢谢。看起来像〜sitecollection /路径工作。尽管我也尝试了/ _catalogs ..但是由于某些原因,这并不起作用。 –