某些Sharepoint控件可能会在回发时表现出不同的 : 我开始时:
<SharePointWebControls:NoteField id="3" FieldName="MultiText" runat="server" />
<PublishingWebControls:RichLinkField id="4" FieldName="Link" runat="server" />
这些控件为空白字段呈现&amp; nbsp。这会在回发时导致不需要的空白。 经过一些研究,我发现了一个类似的解 建议here:
<PublishingWebControls:EditModePanel runat=server id="EditModePanelView" PageDisplayMode="Display" SuppressTag="true">
<SharePointWebControls:FieldValue id="3" FieldName="MultiText" runat="server"/>
<SharePointWebControls:FieldValue id="4" FieldName="Link" runat="server" />
</PublishingWebControls:EditModePanel>
<PublishingWebControls:EditModePanel runat="server" id="EditModePanelEdit">
<SharePointWebControls:NoteField id="7" FieldName="MultiText" runat="server" />
<PublishingWebControls:RichLinkField id="8" FieldName="Link" runat="server" />
</PublishingWebControls:EditModePanel>
...空白字段中没有&amp; nbsp:
现在出现了一个新问题: 当呈现为SharePointWebControls:FieldValue时,在NoteField的编辑模式下输入的任何换行符(呈现为br-Tags)都将丢失。有没有办法在显示模式下呈现NoteField的html?这样休息时间不会丢失,而且没有其他不间断的空间?
答案 0 :(得分:1)
我最终覆盖了Sharepoint控件,如建议的here:
我不得不像这样覆盖NoteField#RenderFieldForDisplay,因此NoteField在回发和GET上的行为相同:
protected override void RenderFieldForDisplay(HtmlTextWriter output)
{
TextWriter writer = new StringWriter();
base.RenderFieldForDisplay(new HtmlTextWriter(writer));
string x= writer.ToString();
string y= " ";
string z= "<br/>";
x= x.Equals(y) ? x.Replace(y, string.Empty) : x.Replace(" ", y).Replace("\r\n", z).Replace("\n", z).Replace("\r", z);
output.Write(x);
}
这很有效,但很糟糕。我仍然不明白为什么sharepoint控件在回发时表现不同并且替换例如带有换行符的标签......