2011-06-02 48 views
1

我在我的页面上使用了FCKEditor。如何在数据库中保存FCKEditor的文本?

,我想节省这样的错误我的网页上A potentially dangerous Request.Form value was detected from the client (LongDescriptionVal="<p>hello..</p>").发生及其对database..but内容..

我在做什么是在这里: -

aspx.cs: -

protected void btnadd_Click(object sender, EventArgs e) 

{ 
    string _detail = Request["LongDescriptionVal"].ToString(); 
    string query = "insert into Description(description) values('" + _detail.Trim() + "')"; 
    SqlCommand cmd = new SqlCommand(query, con); 
    con.Open(); 
    cmd.ExecuteNonQuery(); 
    con.Close(); 
} 

和ASPX: -

<strong>Full Description :</strong> 
       <br /> 
          <!--Editor Code comes here --> 

          <script type="text/javascript"> 
           <!-- 
           var oFCKeditor = new FCKeditor('LongDescriptionVal') ; 
           oFCKeditor.BasePath = 'fckeditor/'; 
           oFCKeditor.Height = 300; 
           oFCKeditor.Value = '<%=FullDescription%>'; 
           oFCKeditor.Create() ; 
           //--> 
          </script> 
        <br /> 
        <asp:Button ID="btnadd" runat="server" Text="Add" OnClick="btnadd_Click" /> 

谁能告诉我,我怎么能保存数据资料基地......

在此先感谢..

+0

感谢所有..现在它正在运行.... – divya 2011-06-02 10:51:38

回答

1

add validateRequest =“false”into your page;

样品;

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" ValidateRequest="false" Inherits="MyApp.Default" %> 
+0

谢谢..现在它正在运行.... – divya 2011-06-02 10:50:49

1

看一看这个问题: A potentially dangerous Request.Form value was detected from the client

答案的要点是,你可以通过设置validateRequest =“假”抑制警告您的aspx文件的< @Page指令。

但是,有一个警告的原因是,这样做可以让你自己面对各种各样的攻击。鉴于您的数据库访问代码的性质,我可以建议您阅读使用参数化查询

1

在aspx页面,设置属性ValidateRequest="False",但不要忘了在数据库中保存之前的输入编码。

相关问题