2011-06-02 12 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",但不要忘了在數據庫中保存之前的輸入編碼。

相關問題