很简单,我有一些Javascript我只想在显示模式下加载,因为click事件会干扰点击内容编辑器Web部件。目前,脚本在显示和编辑模式下加载以下标记:
<PublishingWebControls:EditModePanel runat=server PageDisplayMode="Display">
<script type="text/javascript" src="../_scripts/metroUI.js"></script>
</PublishingWebControls:EditModePanel>
以下是我的命名空间:
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="SharePointWebControls" namespace="Microsoft.SharePoint.WebControls" assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="PublishingWebControls" Namespace="Microsoft.SharePoint.Publishing.WebControls" Assembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePointPortalControls" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="cmsc" namespace="Microsoft.SharePoint.Publishing.WebControls" assembly="Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="WpNs1" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.Office.Server.Search, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="WebControls" namespace="Microsoft.SharePoint.Publishing.WebControls" assembly="Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Taxonomy" Namespace="Microsoft.SharePoint.Taxonomy" Assembly="Microsoft.SharePoint.Taxonomy, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
我错过了什么?
编辑:此外,如果我将页面切换到PageDisplayMode =“编辑”,则脚本不会在任何一个地方加载。
答案 0 :(得分:4)
我把我拥有的东西放在我身上。我唯一注意到的是你的头脑是你有runat = server而不是runat =“server”
恐怕我不知道更多。
<SharePointWebControls:UIVersionedContent UIVersion="4" runat="server">
<ContentTemplate>
<SharePointWebControls:CssRegistration name="<% $SPUrl:~sitecollection/Style Library/~language/Core Styles/page-layouts-21.css %>" runat="server"/>
<PublishingWebControls:EditModePanel runat="server">
<!-- Styles for edit mode only-->
<SharePointWebControls:CssRegistration name="<% $SPUrl:~sitecollection/Style Library/~language/Core Styles/edit-mode-21.css %>"
After="<% $SPUrl:~sitecollection/Style Library/~language/Core Styles/page-layouts-21.css %>" runat="server"/>
</PublishingWebControls:EditModePanel>
<!-- For Javascript that can not be used in publishing mode due to issue with Array.prototype breaking sharepoing. -->
<PublishingWebControls:EditModePanel runat="server" id="Someid" PageDisplayMode="Display" >
<!-- Interactive -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js" type="text/javascript"></script>
</PublishingWebControls:EditModePanel>
</ContentTemplate>
</SharePointWebControls:UIVersionedContent>
答案 1 :(得分:0)
如果您在页面中包含此内容,则可能需要包含SuppressTags =“True”以省略封闭标记。
<PublishingWebControls:EditModePanel runat="server" PageDisplayMode="Display" SuppressTag="True">
[Content here]
</PublishingWebControls:EditModePanel>