1.新建项目,建立editer文件夹,在editer文件夹下加入如下文件,目录结构如下:
<!--StartFragment --><!--StartFragment -->
2.在页面添加如下引用:
- <linkrel="stylesheet"href="editer/themes/default/default.css"/>
- <linkrel="stylesheet"href="editer/plugins/code/prettify.css"/>
- <scriptcharset="utf-8"src="editer/kindeditor.js"></script>
- <scriptcharset="utf-8"src="editer/lang/zh_CN.js"></script>
- <scriptcharset="utf-8"src="editer/plugins/code/prettify.js"></script>
3.在页面添加如下初始化代码:
- <script>
- KindEditor.ready(function(K){
- vareditor1=K.create('<spanstyle="color:#ff0000;">#content1'</span>,{
- 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(){
- varself=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.在页面中使用:
- <textareaid="<spanstyle="color:#ff0000;">content1</span>"cols="100"rows="8"style="width:700px;height:200px;visibility:hidden;“
- runat="server"></textarea>
- //根目录路径,相对路径
- StringrootPath=<spanstyle="color:#ff0000;">"/upload/</span>";
- //根目录URL,可以指定绝对路径,比如http://www.yoursite.com/attached/
- StringrootUrl=<spanstyle="color:#ff0000;">"/upload</span>/";
- //文件保存目录路径
- StringsavePath=<spanstyle="color:#ff0000;">"/upload</span>/";
- //文件保存目录URL
- StringsaveUrl="/<spanstyle="color:#ff0000;">upload</span>/";