SharePoint 中的嵌套母版页不起作用

发布于 2024-08-18 22:32:24 字数 1309 浏览 5 评论 0原文

我有一个 SharePoint 2007 Server,想要创建一个带有嵌套母版页的网站。

我创建了一个新的母版页 test.master:

<%@ Master MasterPageFile="~masterurl/default.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    Test123
    <b>
    <asp:ContentPlaceHolder runat="server" ID="TestPH" Visible="true" />
    </b>
</asp:Content>

然后创建了一个新页面 Test.aspx

<%@ Page MasterPageFile="test.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TestPH" runat="server">
    TestChild
    <asp:Label Text="Test" runat="server" />
</asp:Content>

我使用 SharePoint Designer 将 test.master 和 test.aspx 上传到新创建的空白网站。

当我调用 Test.aspx 时,我只看到 test.master 中的 Test123 - 它似乎忽略了占位符。 HTML 输出(包括 Sharepoint default.master 的摘录):

<td class='ms-bodyareaframe' valign="top" height="100%">
    <A name="mainContent"></A>
    Test123
    <b>

    </b>
</td>

现在,当我进入 Test.aspx 并将其母版页更改为 default.master 并将 TestPH 更改为 PlaceHolderMain 时,我正确地看到了 TestChild Test,因此页面本身可以正常工作。

Master 和 ASPX 页面均不包含 CodeBehind,因此未对 web.config 进行任何更改(SafeControls...)

我想知道是否需要启用某些功能以允许嵌套母版页,或者 SharePoint 2007 是否像往常一样需要牺牲祭坛上有一只山羊……

I have a SharePoint 2007 Server and want to create a site with a nested Master Page.

I created a new Master Page, test.master:

<%@ Master MasterPageFile="~masterurl/default.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    Test123
    <b>
    <asp:ContentPlaceHolder runat="server" ID="TestPH" Visible="true" />
    </b>
</asp:Content>

I then created a new Page, Test.aspx

<%@ Page MasterPageFile="test.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TestPH" runat="server">
    TestChild
    <asp:Label Text="Test" runat="server" />
</asp:Content>

I uploaded both test.master and test.aspx to a newly created blank site using SharePoint Designer.

When I call Test.aspx, I only see Test123 from the test.master - it seems to ignore the placeholder. The HTML Output (including an excerpt from the Sharepoint default.master):

<td class='ms-bodyareaframe' valign="top" height="100%">
    <A name="mainContent"></A>
    Test123
    <b>

    </b>
</td>

Now, when I go into Test.aspx and change it's masterpage to default.master and TestPH to PlaceHolderMain, I correctly see TestChild Test, so the page itself works.

Neither the Master nor the ASPX page contain CodeBehind yet, and thus no change to web.config was made (SafeControls...)

I wonder if I need to enable something to allow nested master pages, or if SharePoint 2007 as usual demands the sacrifice of a goat on it's altar...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

软的没边 2024-08-25 22:32:24

SharePoint 处理母版页令牌的方式有些问题。这是因为它们允许您从数据库加载母版页,而不必位于文件系统中。您可以在此处阅读有关它的更多信息: http://msdn.microsoft.com/ en-us/library/ms476046.aspx

由于我在 1.1 版之后从未使用过“常规 ASP.net”,所以我不知道母版页应该如何工作。
但是,我曾经做过的是将 default.master 的内容(位于 /12/template/global 中)复制到一个不继承任何内容的新文件,然后将其包含在内在站点定义功能中并在 onet.xml 文件中引用它。
该技术如下所述: http://statto1974.wordpress.com/2007/04/30/using-a-custom-master-page-in-a-site-definition/

编辑:但是,有 对此可能有多个参考,例如,这个

There is something about the way SharePoint treats the master-page token. This is because they allow you to load master page from the database, it does not have to be in the file system. You can read more about it here: http://msdn.microsoft.com/en-us/library/ms476046.aspx

Since I've never worked with "regular ASP.net" after version 1.1, I have no idea, how master pages SHOULD work.
But, what I've been doing once, is copying the contents of default.master (lives in /12/template/global) to a new file which does not inherit from anything, then I included it in site definition feature and referenced to it in onet.xml file.
The technique is described here: http://statto1974.wordpress.com/2007/04/30/using-a-custom-master-page-in-a-site-definition/

EDIT: However, there are several references to this being possible, for instance, this one.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文