2017-10-18 129 views
0

我在由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 &lt;any amount you can think of.</p> 

的問題如下,如何以保存的相同方式獲取轉換的數據?我不正確地做什麼來防止這種情況?另外,我忘記提到在C#的後端,在將文本存儲到數據庫之前,我正在使用HttpUtility.HtmlDecode(randomText)

回答

2

我也有kendo Editor的這個問題。但是,我使用ASP.NET包裝,所以我會提供我處理它的方式。希望能幫助到你。

在我的編輯我設置

.Encode(false) 

,在我的表格操作方法提交我設置

[ValidateInput(false)] 

有了這個兩個加法我沒有逃避任何字符。 當然這樣我在我的數據庫中保存了格式化的文本,當我向用戶顯示數據時,格式化的文本顯然是需要的,以便具有相同的格式。