Document directory
- 1. Download the editor
- 2. Deployment Editor
- 4. Introduce the script file (xxx needs to be modified)
- 5. Use the Editor (xxx needs to be modified)
- 6. modify the configuration as needed (file path: WEB \ editor \ Asp.net \ file_manager_json.ashx)
- 7. Get the editor content in the background (xxx needs to be modified)
1. Download editor download kindeditor latest version, download page: http://www.kindsoft.net/down.php
2. Deploy the editor to unzip the kindeditor-x.x.x.zip file and copy the Editor folder to the web directory
3. Add (validaterequest = "false") to the webpage ")
<%@ Page Language="C#" AutoEventWireup="true" ValidateRequest="false" CodeBehind="XXX.cs" Inherits="XXX" %>
4. Introduce the script file (xxx needs to be modified)
<! -- Rich text editor configuration example --> <link type = "text/CSS" rel = "stylesheet" href = ".. /Editor/themes/default/default.css "/> <LINK rel =" stylesheet "href = ".. /Editor/plugins/code/prettify.css "/> <SCRIPT type =" text/JavaScript "charset =" UTF-8 "src = ".. /Editor/kindeditor-min.js "> </SCRIPT> <SCRIPT type =" text/JavaScript "charset =" UTF-8 "src = ".. /Editor/lang/zh_cn.js "> </SCRIPT> <SCRIPT type =" text/JavaScript "charset =" UTF-8 "src =" .. /Editor/plugins/code/prettasks. JS "> </SCRIPT> <SCRIPT type =" text/JavaScript "> kindeditor. ready (function (k) {var editor1 = K. create ('# XXX', {items: ['fontname', 'fontsize',' | ', 'forecolor', 'hilitecolor', 'bold', 'italic ', 'underline', 'removeformat', 'strikethangout', 'lineheight', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', 'insertunorderedlist ', '|', 'emoticons', 'Link', 'insertfile', 'Media ',' | ', 'image', 'multiimage', 'map', 'baidumap', '| ', 'preview', 'fullscreen',], csspath :'.. /Editor/plugins/code/prettify.css ', uploadjson :'.. /Editor/asp.net/upload_json.ashx', filemanagerjson :'.. /Editor/asp.net/file_manager_json.ashx', allowfilemanager: True, pastetype: 1, aftercreate: function () {var self = This; K. CTRL (document, 13, function () {self. sync (); K ('form [name = xxx] ') [0]. submit () ;}); k.ctrl(self.edit.doc, 13, function () {self. sync (); K ('form [name = xxx] ') [0]. submit () ;}}}); prettyprint () ;}); </SCRIPT> <! -- Rich text editor configuration example -->
5. Use the Editor (xxx needs to be modified)
<! -- Rich Text Editor --> <textarea id = "XXX" name = "XXX" runat = "server" Cols = "100" rows = "8" style = "width: 1000px; height: 500px; visibility: hidden; "> </textarea>
6. modify the configuration as needed (file path: WEB \ editor \ Asp.net \ file_manager_json.ashx)
// Root directory path, relative path string rootpath = ".. /.. /"; // root directory URL. You can specify the absolute path string rooturl = aspxurl + ".. /attached/"; // image extension string filetypes =" GIF, JPG, JPEG, PNG, BMP ";
7. Get the editor content in the background (xxx needs to be modified)
Request.Form["XXX"]
Because the content is directly displayed in server programs (Asp, PHP, ASP. NET, etc.), special HTML characters (>,<,&, ") must be converted, so a tool class is written.
When inserting data into a database, replace special characters (xxx must be modified)
HtmlUtil.escapeHtml(Request.Form["XXX"])
Restore special characters when reading data from the database (xxx must be modified)
HtmlUtil.unescapeHtml(XXX)