[英]Parsing special characters in KendoEditor TextArea
在由KendoEditor小部件呈现的文本区域中插入特殊字符时遇到问题。 我已经通过以下方式配置了我的窗口小部件:
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函数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)]
有了这两个添加项,我不必转义任何字符。 当然,通过这种方式,我将格式化的文本保存在数据库中,这显然是使我在向用户显示数据时具有相同格式所必需的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.