码迷,mamicode.com
首页 > 数据库 > 详细

使用文本编辑器时将有样式的文本传入数据库时出现的错误

时间:2014-11-26 13:33:44      阅读:423      评论:0      收藏:0      [点我收藏+]

标签:style   http   io   ar   os   使用   sp   for   strong   

首先下载一个html5编辑器 kindeditor-4.1.10-zh-CN

把下载的kindeditor-4.1.10-zh-CN编辑器里面的文件夹的以下文件放在自己的项目里面

bubuko.com,布布扣bubuko.com,布布扣bubuko.com,布布扣

 

然后在路径:kindeditor-4.1.10-zh-CN\kindeditor-4.1.10\jsp的文件夹中 找到demo.jsp 用记事本打开引用里面的如下:
<!doctype html>
<html>
<head>
    <meta charset="utf-8" />
    <title>KindEditor JSP</title>
    <link rel="stylesheet" href="../themes/default/default.css" />
    <link rel="stylesheet" href="../plugins/code/prettify.css" />
    <script charset="utf-8" src="../kindeditor.js"></script>
    <script charset="utf-8" src="../lang/zh_CN.js"></script>
    <script charset="utf-8" src="../plugins/code/prettify.js"></script>
    <script>
        KindEditor.ready(function(K) {
            var editor1 = K.create(‘textarea[name="content1"]‘, {
                cssPath : ‘../plugins/code/prettify.css‘,
                uploadJson : ‘../jsp/upload_json.jsp‘,
                fileManagerJson : ‘../jsp/file_manager_json.jsp‘,
                allowFileManager : true,
                afterCreate : function() {
                    var self = this;
                    K.ctrl(document, 13, function() {
                        self.sync();
                        document.forms[‘example‘].submit();
                    });
                    K.ctrl(self.edit.doc, 13, function() {
                        self.sync();
                        document.forms[‘example‘].submit();
                    });
                }
            });
            prettyPrint();
        });
    </script>

 

再在.aspx内容页里面添加

 <textarea name="content1"   cols="100" rows="8" style="width:793px;height:200px;"></textarea>
<asp:Button ID="btnOK" runat="server" Text="发表" Height="29px" Width="84px"
            onclick="btnOK_Click" />

 

这时执行页面会发现网页中出现了编辑器

但是当你输入文本之后给它样式并且在编辑器的左上角把文本转化为html的格式后

点击发表要使他保存到数据库时则会出现以下错误:

 

Q:

从客户端(Content="<p>测试</p>")中检测到有潜在危险的 Request.Form 值。 
我已经试过把validateRequest=false 了,但是还是不行,刚接触asp.net的MVC开发模式,各种不是很清楚   & lt;%Html.BeginForm("SubmitAddNews", "News", FormMethod.Post, new { id = "form" });%& gt;   这是提交方式  求大侠给予指点

解决方案:

在主web.config里面加上 <httpRuntime  requestValidationMode="2.0" /> 然后在.aspx页面的pages里面加上 validateRequest="false"

 

这样就ok了

 

使用文本编辑器时将有样式的文本传入数据库时出现的错误

标签:style   http   io   ar   os   使用   sp   for   strong   

原文地址:http://www.cnblogs.com/ss977/p/4122696.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!