【问题标题】:How to have multiple contents in Master Page in ASP如何在 ASP 的母版页中有多个内容
【发布时间】:2014-05-08 14:23:12
【问题描述】:

我有一个难题,我希望我能在这里得到澄清。

我有一个母版页,其中有一个内容占位符,所有其他子页都使用它:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="SiteMaster" %>

<!DOCTYPE html>
<html lang="en">
<head runat="server">
<meta charset="utf-8" />
<title><%: Page.Title %></title>

<!--[if !IE]> -->
<link rel="stylesheet" href="theStyles/adipoli.css" type="text/css" charset="utf-8" />
<!-- <![endif]-->

<script type="text/javascript" src="theScripts/placeholders.jquery.min.js"></script>
<script type="text/javascript" src="theScripts/jquery.appear.js"></script>

<!-- default stylesheets -->
<link rel="stylesheet" type="text/css" href="theStyles/defaultStyle.css" />
<link rel="stylesheet" type="text/css" href="theStyles/captionStyle.css" />
<link rel="stylesheet" type="text/css" href="theStyles/footerLinks.css" />
<!-- end default stylesheets -->

<!-- if IE version 9 or less -->
<!--[if lte IE 9]>
<link rel="stylesheet" type="text/css" href="theStyles/defaultStyle_ie.css" />
<link rel="stylesheet" type="text/css" href="theStyles/captionStyle_ie.css" />
<![endif]-->

</head>
<body>
    <form runat="server">
        <asp:ContentPlaceHolder runat="server" ID="FeaturedContent" />
<!-- ################################################################################ -->
<!-- ###                                                                          ### -->
<!-- ### The below contents will be visible in every page unless otherwise stated ### -->
<!-- ###                                                                          ### -->
<!-- ################################################################################ -->
<!-- ### BEGIN LEFT SIDE MENU ### -->
<!-- ### END LEFT SIDE MENU ### -->
<!-- ### BEGIN TOP RIBBON ### -->
<div id="headerRibbon">
    <span id="socialIcons">
        <asp:HyperLink title="Compant Homepage" href="Default.aspx" ClientIDMode="Static" runat="server">
            <asp:Image src="theImages/wmlogo.png" width="219" height="47" alt="Compant Medical Group Homepage" title="Compant Medical Group Homepage" runat="server" />
        </asp:HyperLink>
    </span>

    <div id="tSearch">
        <!--[if lte IE 8]>
            <input id="searchText" name="" type="text" size="40" placeholder="Search Compant" />
        <![endif]-->
        <!--[if gte IE 9]><!--> 
            <asp:TextBox ClientIDMode="Static" ID="searchText" size="40" placeholder="Search" runat="server"></asp:TextBox>
        <!--<![endif]--> 
    </div>
</div>
<!-- ### END TOP RIBBON ### -->

<!-- ### BEGIN BOTTOM RIBBON ### -->
<div id="strip">
</div>
<div id="footerRibbon" class="footerRibbon">
    <asp:Label runat="server" ClientIDMode="Static" ID="copyRight" Text="© 2009-14 COMPANY"></asp:Label>
</div>
<!-- ### END BOTTOM RIBBON ### -->
        <script type="text/javascript" src="theScripts/defaultScript.js"></script>
    </form>
</body>
</html>

关于我们

<%@ Page Title="About" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeFile="about.aspx.cs" Inherits="about" %>

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="FeaturedContent">

</asp:Content>

联系方式

<%@ Page Title="Contact" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeFile="contact.aspx.cs" Inherits="contact" %>

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="FeaturedContent">

</asp:Content>

这是它的外观快照:

我的问题是,如果 aboutus 页面中有 Webparts 有它自己的 HTML 代码,我希望某些用户能够对其进行编辑。我设置母版页的方式可以实现吗?还是我必须为每个子页面设置单独的 contentplaceholder 才能实现它?

【问题讨论】:

  • Webparts 是什么意思?使用它可以轻松编辑 body 标签内的内容。
  • 在 SharePoint 中,Webpart 几乎是可编辑的内容。我可以在内容占位符内添加 Webpart 吗?
  • 另外,我会从母版页中删除 form runat=server 并将其添加到需要的特定页面中
  • 不知道这是可能的。感谢您的提示:)
  • 我不确定webparts 是什么。您应该添加有问题的sharepoint 标签。只要您想在body标签中添加一些东西,您就应该很好。但从母版页中删除 runat=server

标签: html asp.net css sharepoint-2013 contentplaceholder


【解决方案1】:

如果您想创建支持所有共享点功能(如功能区)的 SharePoint 母版页,我建议您采用标准母版页并进行更改,而不是从头开始创建新的母版页。

您当前的母版页不支持 Web 部件,因为您没有所有必需的 javascript、css 文件、控件等。包含在其中。例如,您需要在页面上有SPWebPartManager 控件以支持 Web 部件(包含在标准母版页中)。

添加所有必要的内容后,下一步是向您的页面添加WebPartZone 控件,以允许最终用户向页面添加 Web 部件。

<WebPartPages:WebPartZone runat="server" FrameType="Standard" ID="MainHeader" Title="loc:Main Header">
    <ZoneTemplate>
    </ZoneTemplate>
</WebPartPages:WebPartZone>

【讨论】:

    猜你喜欢
    • 2011-02-21
    • 1970-01-01
    • 2017-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-19
    • 2014-03-04
    • 1970-01-01
    相关资源
    最近更新 更多