KinderEditor编辑器 在Asp.Net中的使用

KinderEditor编辑器 在Asp.Net中的使用

KinderEditor编辑器的使用 分为简单的三步。

1:添加引用部分

<script src="/KinderEditor/kindeditor-min.js"></script>
<link rel="stylesheet" href="/KinderEditor/themes/default/default.css" />
<link rel="stylesheet" href="/KinderEditor/plugins/code/prettify.css" />
<script charset="utf-8" src="/KinderEditor/kindeditor.js"></script>
<script charset="utf-8" src="/KinderEditor/lang/zh_CN.js"></script>
<script charset="utf-8" src="/KinderEditor/plugins/code/prettify.js"></script>

这里注意,路径记得修改!如果同样添加到了web层的根目录就不用修改了!

KinderEditor编辑器 在Asp.Net中的使用

2:添加JS代码

<script type="text/javascript">
KindEditor.ready(function (K) {
var editor1 = K.create('#MsgContent', {
cssPath: '/KinderEditor/plugins/code/prettify.css',
uploadJson: '/KinderEditor/asp.net/upload_json.ashx',
fileManagerJson: '/KinderEditor/asp.net/file_manager_json.ashx',
allowFileManager: true,
afterBlur: function () { this.sync(); },//注意这里(异步提交时需要同步)
afterCreate: function () {
var self = this;
self.sync();//把富文本编辑器的内容放到 文本域里面去。

}
});
prettyPrint();//注意要调用该方法.
});
</script>

3:添加文本区域代码

<textarea id="MsgContent" cols="100" rows="8" style=" 500px; height: 200px; visibility: hidden;" name="Msg"></textarea>

文件下载:链接: http://pan.baidu.com/s/1c0uajuw 密码: 4nse

如果完善上传图功能及的引用LibJSON,在文件夹KinderEditorasp.netin内

在这里修改文件保存路径:

KinderEditor编辑器 在Asp.Net中的使用

//文件保存目录路径
 String savePath = "/Upload/KinderEditorImages/";