解析KendoEditor中的特殊字符TextArea
问题描述:
我在由KendoEditor小部件呈现的textarea中插入特殊字符时遇到问题。我已经通过以下方式配置了我的小部件:解析KendoEditor中的特殊字符TextArea
function configureRequestNotesEditor() {
$("#notes").kendoEditor({
resizable: {
content: true
},
pasteCleanup: {
all: true,
css: true,
keepNewLines: true,
msAllFormatting: true,
msConvertLists: true,
msTags: true,
none: false,
span: false
},
tools: [
"bold", "underline", "insertUnorderedList", "insertOrderedList", "indent", "outdent"
]
});
};
当我将数据发送到我的api时,我使用javascript函数escape()
,当我从api调用javascript函数返回时调用javascript函数unescape()
。 ,我输入到textarea的字段中的文本如下:
Send to James in UW ASAP. See attached files. How long is this field?
300
The amount should be <any amount you can think of.
当数据保存,然后呈现回UI被打印到屏幕
<p>Send to James in UW ASAP. See attached files. How long is t his field?</p><p>300</p><p>The amount should be <any amount you can think of.</p>
的问题如下,如何以保存的相同方式获取转换的数据?我不正确地做什么来防止这种情况?另外,我忘记提到在C#的后端,在将文本存储到数据库之前,我正在使用HttpUtility.HtmlDecode(randomText)
。
答
我也有kendo Editor的这个问题。但是,我使用ASP.NET包装,所以我会提供我处理它的方式。希望能帮助到你。
在我的编辑我设置
.Encode(false)
,在我的表格操作方法提交我设置
[ValidateInput(false)]
有了这个两个加法我没有逃避任何字符。 当然这样我在我的数据库中保存了格式化的文本,当我向用户显示数据时,格式化的文本显然是需要的,以便具有相同的格式。