我使用SharePoint Designer 2013编辑页面布局文件(* .aspx)。我尝试使用其“Html”属性将默认文本设置为RichHtmlField,但它无法正常工作。我尝试了“文本”属性,它也无法正常工作。我如何使它工作?
<PublishingWebControls:RichHtmlField id="PageContent" FieldName="PublishingPageContent" MinimumEditHeight="400px" DisableInputFieldLabel="true" Html="<html><span><p>Objectives</p></span></html>" runat="server"/>
答案 0 :(得分:0)
尝试使用Publishing:HtmlEditor这将允许您设置HTML属性。我在Visual Studio的自定义应用程序页面中使用它,所以我不知道这是否适用于SharePoint Designer。我的需要是拥有默认的html编辑文本框。它适用于我们的环境:
<Publishing:HtmlEditor ID="htmlEditor" BorderWidth="1" BorderStyle="Solid" runat="server" />
<div ID="HtmlEditorTextBox" visible="false" runat="server" style="background-color: #F0F0F0; color: rgb(84, 84, 84); border:1px solid gray;width:400px;height:200px;overflow:auto;"></div>
在代码隐藏中,我可以像这样解决编辑器:
htmlEditor.Field = new RichHtmlField();
htmlEditor.Field.HasInitialFocus = false;
htmlEditor.Field.ControlMode = Microsoft.SharePoint.WebControls.SPControlMode.New;
htmlEditor.Field.EnableViewState = true;
htmlEditor.Field.AllowReusableContent = false;
htmlEditor.Field.MinimumEditHeight = "200px";
htmlEditor.Html = "<b>Hello</b>";
HtmlEditorTextBox.InnerHtml = "<b>Hello</b>";
确保在aspx页面中包含此内容:
<%@Register TagPrefix="Publishing" Assembly="Microsoft.SharePoint.Publishing, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.Publishing.WebControls"%>