日期:2014-05-17  浏览次数:21017 次

kindeditor在asp.net中的使用

1.新建项目,建立editer文件夹,在editer文件夹下加入如下文件,目录结构如下:

<!--StartFragment -->
<!--StartFragment -->
?
2.在页面添加如下引用:
<link rel="stylesheet" href="editer/themes/default/default.css" />
<link rel="stylesheet" href="editer/plugins/code/prettify.css" />
<script charset="utf-8" src="editer/kindeditor.js"></script>
<script charset="utf-8" src="editer/lang/zh_CN.js"></script>
<script charset="utf-8" src="editer/plugins/code/prettify.js"></script>
?
3.在页面添加如下初始化代码:
<script>
    KindEditor.ready(function (K) {
        var editor1 = K.create('#content1', {
            cssPath: 'editer/plugins/code/prettify.css',
            uploadJson: 'editer/asp.net/upload_json.ashx',
            fileManagerJson: 'editer/asp.net/file_manager_json.ashx',
            allowFileManager: true,
            afterCreate: function () {
                var self = this;
                K.ctrl(document, 13, function () {
                    self.sync();
                    K('form[name=example]')[0].submit();
                });
                K.ctrl(self.edit.doc, 13, function () {
                    self.sync();
                    K('form[name=example]')[0].submit();
                });
            }
        });
        prettyPrint();
    });
</script>
?
4.在页面中使用:
<textarea id="content1" cols="100" rows="8" style="width:700px;height:200px;visibility:hidden;“
 runat="server"></textarea>
?5.修改?file_manager_json.ashx,在什么目录结构中,上传文件路径为upload。
//根目录路径,相对路径
String rootPath = "/upload/";
//根目录URL,可以指定绝对路径,比如 http://www.yoursite.com/attached/
String rootUrl =  "/upload/";
?
6.修改upload_json.ashx
//文件保存目录路径
String savePath = "/upload/";
//文件保存目录URL
String saveUrl = "/upload/";
?