<%@ Page Language="C#" AutoEventWireup="true" ValidateRequest="false" CodeBehind="XXX.cs" Inherits="XXX" %>
<!--富文本编辑器配置↓ --> <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, 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> <!--富文本编辑器配置↑-->
<!--富文本编辑器--> <textarea id="XXX" name="XXX" runat="server" cols="100" rows="8" style="width:1000px;height:500px;visibility:hidden;"></textarea>
//根目录路径,相对路径 String rootPath = "../../"; //根目录URL,可以指定绝对路径 String rootUrl = aspxUrl + "../attached/"; //图片扩展名 String fileTypes = "gif,jpg,jpeg,png,bmp";
Request.Form["XXX"]
public class HtmlUtil { /// <summary> /// 替换HTML特殊字符 /// </summary> /// <param name="content"></param> /// <returns></returns> public static String escapeHtml(String content) { return content.Replace("&", "&") .Replace("<", "<") .Replace(">", ">") .Replace("\"", """); } /// <summary> /// 还原HTML特殊字符 /// </summary> /// <param name="content"></param> /// <returns></returns> public static String unescapeHtml(String content) { return content.Replace("&", "&") .Replace("<", "<") .Replace(">", ">") .Replace(""", "\""); } }往数据库插入时,进行替换特殊字符(XXX部分需要修改)
HtmlUtil.escapeHtml(Request.Form["XXX"])
HtmlUtil.unescapeHtml(XXX)