1. Download Editor
Download kindeditor latest version, download page: http://www.kindsoft.net/down.php
2. Deployment Editor
Unzip the Kindeditor-x.x.x.zip file and copy the Editor folder to the Web directory
3, in the Web page to add (validaterequest= "false")
Copy Code code as follows:
<%@ Page language= "C #" autoeventwireup= "true" validaterequest= "false" codebehind= "XXX.cs" inherits= "XXX"%>
4, the introduction of script files (XXX part needs to be modified)
Copy Code code as follows:
<!--Rich Text editor configuration ↓-->
<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/prettify.js "></script>
<script type= "Text/javascript" >
Kindeditor.ready (function (K) {
var editor1 = k.create (' #XXX ', {
Items: [
' FontName ', ' fontsize ', ' | ', ' forecolor ', ' hilitecolor ', ' bold ', ' italic ', ' underline ',
' Removeformat ', ' strikethrough ', ' 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, function () {
Self.sync ();
K (' form[name=xxx] ') [0].submit ();
});
K.ctrl (Self.edit.doc, function () {
Self.sync ();
K (' form[name=xxx] ') [0].submit ();
});
}
});
Prettyprint ();
});
</script>
<!--Rich Text editor configuration ↑-->
5. Use editor (XXX part needs to be modified)
Copy Code code as follows:
<!--Rich Text editor-->
<textarea id= "xxx" name= "xxx" runat= "server" cols= "rows=" 8 "style=" width:1000px;height:500px;visibility: hidden; " ></textarea>
6, according to their own needs to modify the configuration(File path: web\editor\asp.net\file_manager_json.ashx)
Copy Code code as follows:
root directory path, relative path
String RootPath = ".. /.. /";
Root URL, you can specify an absolute path
String Rooturl = Aspxurl + ". /attached/";
Picture extension
String filetypes = "Gif,jpg,jpeg,png,bmp";
7, backstage get editor content(XXX part needs to be modified)
Copy Code code as follows:
Because of server-side programs (ASP, PHP, ASP.) NET etc.), you must convert the HTML special character (>,<,&, "), so write a tool class
Copy Code code as follows:
public class Htmlutil
{
<summary>
Replace HTML special characters
</summary>
<param name= "Content" ></param>
<returns></returns>
public static string escapehtml (string content)
{
return content. Replace ("&", "&")
. Replace ("<", "<")
. Replace (">", ">")
. Replace ("\" "," "");
}
<summary>
Restore HTML special characters
</summary>
<param name= "Content" ></param>
<returns></returns>
public static string unescapehtml (string content)
{
return content. Replace ("&", "&")
. Replace ("<", "<")
. Replace (">", ">")
. Replace ("" "," \ ");
}
}
Replace special characters when inserting to database (XXX part needs to be modified)
Copy Code code as follows:
Htmlutil.escapehtml (request.form["XXX"])
To restore special characters when reading data from a database (the XXX section needs to be modified)
Copy Code code as follows:
Htmlutil.unescapehtml (XXX)