日期:2014-05-17  浏览次数:20616 次

jhl52771请进,第二帖 关于留言本使用FCK取值等问题
之前用textarea都写好了,现在要把textarea替换成fck,fck已经可以显示了,现在的问题是,我直接把我认为该修改的都修改了,但提交【回复留言】,却不行,查了下数据库,插入的都是空值,不知道哪里错了,请指教。
下面是相关代码:
C# code

 t += "" + "<input type=button value='删除此留言' onclick='deleteData(" + id + ")'/><tr/>";
                                       t += "" + "<div><input type='hidden' id='FckNewsContent' name='FckNewsContent' value='' /><input type='hidden' id='FckNewsContent___Config' value='HtmlEncodeOutput=true' /><iframe id='FckNewsContent___Frame' src='fckeditor/editor/fckeditor.html?InstanceName=FckNewsContent&amp;Toolbar=Default' width='700px' height='400px' frameborder='no' scrolling='no'></iframe></div><tr/>";
                                       t += "" + "<input id=replybutton type=button value='回复此留言' onclick='replyData(" + id + ")'/><tr/>";
       

                                

 function replyData(id) { //回复留言函数
                          
                           var textarea1 = getEditorHTMLContents("FckNewsContent");
                           
                           $.ajax({
                               type: "POST",
                               cache: false,
                               url: "WebService.asmx/Update", /* 注意后面的名字对应CS的方法名称 */

                               data: { "id": id, "textarea1": textarea1 }, /* 注意参数的格式和名称 */
                               contentType: "application/x-www-form-urlencoded",
                               dataType: "xml",
                               success: function (ret) {

                                   //判断 ret 删除成功再决定是否刷新getData();
                                   getData();
                               }

                           });
                       }




 [WebMethod]
    public String Update(int id, string textarea1)
    {
        System.Data.SqlClient.SqlConnection sqlCon = new SqlConnection();
        sqlCon.ConnectionString = "server=.;uid=sa;pwd=sa;database=guestbook";
        //定义SQL语句
        //string SqlStr = "update gbook set repcontent='" + textarea1 + "' where id=" + id;
        string SqlStr = string.Format("update gbook set repcontent='{0}' where id={1}", textarea1, id);
        //实例化SqlDataAdapter对象
        sqlCon.Open();
        SqlCommand cmd = new SqlCommand(SqlStr, sqlCon);
        int ret = cmd.ExecuteNonQuery();
        sqlCon.Close();
        if (ret > 0) return "回复成功";
        return "回复失败";
    }
    


------解决方案--------------------
我看你ID都是一个FckNewsContent


FckNewsContent+Id作个标识
------解决方案--------------------
<div><input type='hidden' id='FckNewsContent' name='FckNewsContent' value='' /><input type='hidden' id='FckNewsContent___Config' value='HtmlEncodeOutput=true' /><iframe id='FckNewsContent___Frame' src='fckeditor/editor/fckeditor.html?InstanceName=FckNewsContent&amp;Toolbar=Default' width='700px' height='400px' frameborder='no' scrolling='no'></iframe></div>


这里面的也要换
------解决方案--------------------
你最好拿个单独页面测测。。