使用版本:4.1.7
根據官網提示進行瘦身(看官網),配置如下:
一,webconfig中:
<configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> <httpRuntime requestValidationMode="2.0" /> </system.web> </configuration>
二、頁面頭部,一定要加上ValidateRequest="false":
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" ValidateRequest="false" Inherits="WebTest.WebForm2" %>
以上是避免請求數據檢查時,報錯:傳輸數據有風險。
三、HTML代碼:
<textarea id="textContent" name="Descirpt" cols="70" rows="35" style="width: 700px; height: 400px; visibility: hidden;" enableviewstate="true"></textarea>
四、初始化KindEditor並為其賦值,這里封裝到一個方法里面,可以在AJAX請求完成后,調用方法並把數據綁定到textarea中。其中,editor是全局變量,方便以后取值。
var editor; //綁定數據 function bindData(data) { var options = { width: '700px', height: '400px', uploadJson: '/Scripts/KindEditor/asp.net/upload_json.ashx', fileManagerJson: '/Scripts/KindEditor/asp.net/file_manager_json.ashx', allowFileManager: true, afterBlur: function () { this.sync(); }, afterCreate: function () { this.sync(); } } editor = KindEditor.create('#textContent', options); prettyPrint(); editor.html(data); }
五、修改完成后,取值就簡單了,直接就是:editor.html()。。
在此,特別感謝:老胡,大哥權,為樂。提供分析思路和幫助!!