使用版本: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()。。
在此,特别感谢:老胡,大哥权,为乐。提供分析思路和帮助!!