Sharepoint 控件在回发时的不同行为
遗憾的是,一些 Sharepoint 控件在回发时表现不同: 我从以下开始:
<SharePointWebControls:NoteField id="3" FieldName="MultiText" runat="server" />
<PublishingWebControls:RichLinkField id="4" FieldName="Link" runat="server" />
这些控件呈现空白字段。这会导致回发时出现不需要的空白。 经过一番研究,我找到了一个解决方案,例如 建议 此处 :
<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>
...不再有空白字段:
- 在编辑模式下,使用特定的 WebControl。
- 在页面的显示模式中,使用 SharepointWebControls:FieldValue 来简单地呈现内容。
现在又出现了新的问题: 当呈现为 SharePointWebControls:FieldValue 时,在 NoteField 的编辑模式下输入的任何换行符(呈现为 br-Tags)都会丢失。有什么方法可以像显示模式一样渲染 NoteField 的 html 吗?这样分行就不会丢失并且没有额外的非分行空格?
Some Sharepoint controls sadly behave different on postback:
I started with:
<SharePointWebControls:NoteField id="3" FieldName="MultiText" runat="server" />
<PublishingWebControls:RichLinkField id="4" FieldName="Link" runat="server" />
These controls render   for blank fields. That lead to unwanted whitespace on postback.
After some research I found a solution like
suggested 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>
...no   in blank fields anymore:
- In Edit-Mode the specific WebControls are used.
- In display mode of the page, there is used SharepointWebControls:FieldValue to simply render the content.
Now a new problem occured:
Any line breaks (rendered as br-Tags) that are entered in edit mode for a NoteField are lost, when rendered as SharePointWebControls:FieldValue. Is there any way to render the html of the NoteField as is in display mode? So that the breaks don't get lost and there are no additional non-breaking spaces?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最终按照建议覆盖了 Sharepoint 控件 此处:
我必须覆盖NoteField#RenderFieldForDisplay 这样,这样 NoteField在回发和 GET 上的行为相同:
这可以工作,但很糟糕。我仍然不明白为什么共享点控件在回发时表现不同,并将例如 br-Tags 替换为换行符......
I ended up with overwriting the Sharepoint Controls like suggested here:
I had to overwrite NoteField#RenderFieldForDisplay like this, so that NoteField behaves the same on postback and on GET:
This works but it sucks. I still don't get it why sharepoint controls behave different on postback and replace e.g. br-Tags with line breaks...