C# 如何在 Sharepoint 多行字段中插入新行?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1343079/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to insert a new line into a Sharepoint multiple line field?
提问by Jared
I am inserting items into a Sharepoint list using C# and accessing the lists.asmx web service. One of the fields in the list is a multiple line text field (rich text), and I want to insert line breaks into the field. What characters do I put in the XML request to insert a line break? Thanks.
我正在使用 C# 将项目插入 Sharepoint 列表并访问lists.asmx Web 服务。列表中的字段之一是多行文本字段(富文本),我想在该字段中插入换行符。我在 XML 请求中放入哪些字符来插入换行符?谢谢。
采纳答案by Colin
I have the same setup as you and I tired <br />
but it won't translate over if you are using an XML element to update the list.
我和你有相同的设置,<br />
但我很累,但如果你使用 XML 元素来更新列表,它不会转换。
When your generating your text, use <![CDATA[<br/>]]>
instead of <br />
.
生成文本时,请使用<![CDATA[<br/>]]>
代替<br />
。
This will translate over, tested and verified.
这将被翻译、测试和验证。
回答by Colin
You can add <br />
tags to the text. the content of the field is stored in a CDATA element.
您可以<br />
为文本添加标签。该字段的内容存储在 CDATA 元素中。
回答by Neville
System.Environment.NewLine
I had the exact same problem, but neither <br />
nor <br/>
worked for me within <![CDATA[
In the end I removed CDATA and treated the text as a regular string, inserting the System.Environment.NewLine
property where ever a line break was needed.
我遇到了完全相同的问题,但既没有<br />
也没有<br/>
为我工作<![CDATA[
最后我删除了 CDATA 并将文本视为常规字符串,System.Environment.NewLine
在需要换行符的地方插入属性。