Asp. NET Web site using the Kindeditor Rich Text Editor configuration steps _ Practical Tips

Source: Internet
Author: User
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:

request.form["XXX"]

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)
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.