之前用textarea都写好了,现在要把textarea替换成fck,fck已经可以显示了,现在的问题是,我直接把我认为该修改的都修改了,但提交【回复留言】,却不行,查了下数据库,插入的都是空值,不知道哪里错了,请指教。
下面是相关代码: 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 "回复失败";
    }
    

解决方案 »

  1.   


      <script>
                                function getEditorHTMLContents(EditorName) {
      var oEditor = FCKeditorAPI.GetInstance(EditorName);
      var editorHtml = (oEditor.GetXHTML(true)); ;
      //alert(editorHtml);
      return editorHtml;
      }
      </script>这里还有一段,取消掉alert注释,将得到一个对话框,但也仅仅得到这么一个对话框,查饿了下数据库,写入的还是一个个空值
      

  2.   

    我看你ID都是一个FckNewsContent  
    FckNewsContent+Id作个标识
      

  3.   

    具体是哪些要替换呢,我真不熟悉jquery,我把我觉得该添加的添加上了,还是不对
    var textarea1 = getEditorHTMLContents("FckNewsContent"+id);
      

  4.   

    <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>
    这里面的也要换
      

  5.   

     function getEditorHTMLContents(EditorName) {
                                    // alert(EditorName.toString());
                                    var oEditor = FCKeditorAPI.GetInstance(EditorName);
                                   // alert(oEditor);
      var editorHtml = (oEditor.GetXHTML(true));
      //alert(editorHtml);
      return editorHtml;提示上面的代码出错:Microsoft JScript 运行时错误: 无法获取属性“GetXHTML”的值: 对象为 null 或未定义
      

  6.   

    依我看,是这句
                                           t += "" + "<div><input type='hidden' id='FCKeditor1' name='FCKeditor1' value='' /><input type='hidden' id='FCKeditor1___Config' value='HtmlEncodeOutput=true' /><iframe id='FCKeditor1___Frame' src='fckeditor/editor/fckeditor.html?InstanceName=FCKeditor1&amp;Toolbar=Default' width='700px' height='400px' frameborder='no' scrolling='no'></iframe></div><tr/>";的问题,就是获取不到这句的id,不知道这句的ID是什么
      

  7.   

    <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>
    上面是右键FK生成的HTML源码 你可以拼这个--------------
    这个你是怎么算出来的呢