標籤:href row inherits this ida 伺服器端 zip css list
1. 下載編輯器
下載 KindEditor 最新版本,下載頁面: http://www.kindsoft.net/down.php
2. 部署編輯器
解壓 kindeditor-x.x.x.zip 檔案,將editor檔案夾複製到web目錄下
3、在網頁中加入(ValidateRequest="false")
1 <%@ Page Language="C#" AutoEventWireup="true" ValidateRequest="false" CodeBehind="XXX.cs" Inherits="XXX" %>
4、引入指令檔(XXX部分需要修改)
1 <!--富文字編輯器配置↓ --> 2 <link type="text/css" rel="stylesheet" href="../editor/themes/default/default.css" /> 3 <link rel="stylesheet" href="../editor/plugins/code/prettify.css" /> 4 <script type="text/javascript" charset="utf-8" src="../editor/kindeditor-min.js"></script> 5 <script type="text/javascript" charset="utf-8" src="../editor/lang/zh_CN.js"></script> 6 <script type="text/javascript" charset="utf-8" src="../editor/plugins/code/prettify.js"></script> 7 <script type="text/javascript"> 8 KindEditor.ready(function (K) { 9 var editor1 = K.create(‘#XXX‘, { 10 items: [ 11 ‘fontname‘, ‘fontsize‘, ‘|‘, ‘forecolor‘, ‘hilitecolor‘, ‘bold‘, ‘italic‘, ‘underline‘, 12 ‘removeformat‘, ‘strikethrough‘, ‘lineheight‘, ‘|‘, ‘justifyleft‘, ‘justifycenter‘, ‘justifyright‘, ‘insertorderedlist‘, 13 ‘insertunorderedlist‘, ‘|‘, ‘emoticons‘, ‘link‘, ‘insertfile‘, ‘media‘, ‘|‘, ‘image‘, ‘multiimage‘, ‘map‘, ‘baidumap‘, ‘|‘, ‘preview‘, ‘fullscreen‘, 14 ], 15 cssPath: ‘../editor/plugins/code/prettify.css‘, 16 uploadJson: ‘../editor/asp.net/upload_json.ashx‘, 17 fileManagerJson: ‘../editor/asp.net/file_manager_json.ashx‘, 18 allowFileManager: true, 19 pasteType: 1, 20 afterCreate: function () { 21 var self = this; 22 K.ctrl(document, 13, function () { 23 self.sync(); 24 K(‘form[name=XXX]‘)[0].submit(); 25 }); 26 K.ctrl(self.edit.doc, 13, function () { 27 self.sync(); 28 K(‘form[name=XXX]‘)[0].submit(); 29 }); 30 } 31 }); 32 prettyPrint(); 33 }); 34 </script> 35 <!--富文字編輯器配置↑-->
5、使用編輯器(XXX部分需要修改)
1 <!--富文字編輯器--> 2 <textarea id="XXX" name="XXX" runat="server" cols="100" rows="8" style="width:1000px;height:500px;visibility:hidden;"></textarea>
6、根據自己的需要修改配置(檔案路徑:web\editor\asp.net\file_manager_json.ashx)
1 //根目錄路徑,相對路徑 2 String rootPath = "../../"; 3 //根目錄URL,可以指定絕對路徑 4 String rootUrl = aspxUrl + "../attached/"; 5 //圖片副檔名 6 String fileTypes = "gif,jpg,jpeg,png,bmp";
7、後台擷取編輯器內容(XXX部分需要修改)
1 Request.Form["XXX"]
由於伺服器端程式(ASP、PHP、ASP.NET等)直接顯示內容,則必須轉換HTML特殊字元(>,<,&,”),所以寫了個工具類
1 public class HtmlUtil 2 { 3 /// <summary> 4 /// 替換HTML特殊字元 5 /// </summary> 6 /// <param name="content"></param> 7 /// <returns></returns> 8 public static String escapeHtml(String content) 9 { 10 return content.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace("\"", """); 11 } 12 /// <summary> 13 /// 還原HTML特殊字元 14 /// </summary> 15 /// <param name="content"></param> 16 /// <returns></returns> 17 public static String unescapeHtml(String content) 18 { 19 return content.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace(""", "\""); 20 } 21 }
往資料庫插入時,進行替換特殊字元(XXX部分需要修改)
1 HtmlUtil.escapeHtml(Request.Form["XXX"])
從資料庫讀取資料時,進行還原特殊字元(XXX部分需要修改)
1 HtmlUtil.unescapeHtml(XXX)
ASP.NET網站使用Kindeditor富文字編輯器配置步驟