Asp. NET Web site using the Kindeditor Rich Text editor configuration steps

Source: Internet
Author: User

1. Download the 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. Add (validaterequest= "false") to the webpage

1 <%@ page language="C #" autoeventwireup="true" validaterequest="false" codebehind="XXX.cs" Inherits ="XXX"

4, the introduction of script files (XXX part needs to be modified)

1<!--Rich Text editor configuration ↓-->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 varEditor1 = K.create ('#XXX', { Ten items: [ One 'FontName','fontsize','|','ForeColor','Hilitecolor','Bold','Italic','Underline',  A 'Removeformat','Strikethrough','lineheight','|','Justifyleft','Justifycenter','Justifyright','insertorderedlist',  - 'insertunorderedlist','|','Emoticons','Link','InsertFile','Media','|','Image','Multiimage','Map','Baidumap','|','Preview','fullscreen',  - ],  theCsspath:'.. /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 () { + varSelf = This;  AK.ctrl (document, -, function () { at Self.sync (); -K'Form[name=xxx]')[0].submit ();  - });  -K.ctrl (Self.edit.doc, -, function () { - Self.sync (); -K'Form[name=xxx]')[0].submit ();  in });  - }  to });  + Prettyprint (); - });  the</script> *<!--Rich Text editor configuration ↑-->

5, using the editor (XXX part needs to be modified)

1 2 <textarea id="xxx" name="xxx " runat= " Server " cols= " "rows="8" style="  Width:1000px;height:500px;visibility:hidden; "

6, according to their own needs to modify the configuration (file path: web\editor\asp.net\file_manager_json.ashx)

1 //root directory path, relative path2String RootPath =".. /.. /"; 3 //root directory URL, you can specify an absolute path4String Rooturl = Aspxurl +".. /attached/"; 5 //Picture Extension6String filetypes ="gif,jpg,jpeg,png,bmp";

7, Backstage get editor content (XXX part needs to modify)

1 request.form["XXX"]

Due to server-side programs (ASP, PHP, ASP. NET, etc.), you must convert the HTML special characters (>,<,&, "), so I wrote a tool class

1  Public classHtmlutil2  { 3         /// <summary> 4         ///Replace HTML special characters5         /// </summary> 6         /// <param name= "content" ></param> 7         /// <returns></returns> 8          Public Staticstring escapehtml (string content)9         { Ten            returnContent. Replace ("&","&"). Replace ("<","<"). Replace (">",">"). Replace ("\"",""");  One         }  A         /// <summary>  -         ///Restore HTML special characters -         /// </summary>  the         /// <param name= "content" ></param>  -         /// <returns></returns>  -          Public Staticstring unescapehtml (string content) -         {  +             returnContent. Replace ("&","&"). Replace ("<","<"). Replace (">",">"). Replace (""", "\"");  -         }  +}

Replace special characters when inserting to the database (XXX section needs to be modified)

1 htmlutil.escapehtml (request.form["XXX"])

Special characters to be restored when reading data from the database (XXX section needs to be modified)

1 htmlutil.unescapehtml (XXX)

Asp. NET Web site using the Kindeditor Rich Text editor configuration steps

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.