留言本项目,【回复留言】的相关代码,要求用jquery实现回复留言后无刷新更新留言列表,并且要使用FCKeditor编辑器接收管理员回复的内容。我自己写的如下代码,无法引用FCKeditor1的id和value属性。   [WebMethod]
   public String Reply(int id,string FCKeditor1.Value)
   {
   System.Data.SqlClient.SqlConnection sqlCon = new SqlConnection();
   sqlCon.ConnectionString = "server=.;uid=sa;pwd=sa;database=guestbook";
   //定义SQL语句
   string SqlStr = "update gbook set repcontent=" + FCKeditor1.Value + "where id=" + id;
   //实例化SqlDataAdapter对象
   sqlCon.Open();
   SqlCommand cmd = new SqlCommand(SqlStr, sqlCon);
   int ret = cmd.ExecuteNonQuery();
   sqlCon.Close();
   if (ret > 0) return "回复成功";
   return "回复失败";
   }<div style="height: 205px">
   <FCKeditorV2:FCKeditor id="FCKeditor1" runat="server" DefaultLanguage="zh-cn" Visible="False" />
   </div>  
  
  function replyData(id,FCKeditor1.Value) {
   $.ajax({
   type: "POST",
   cache: false,
   url: "WebService.asmx/Reply", /* 注意后面的名字对应CS的方法名称 */
   data: { "id": id }, /* 注意参数的格式和名称 */
   contentType: "application/x-www-form-urlencoded",
   dataType: "xml",
   success: function (ret) {   //判断 ret 删除成功再决定是否刷新getData();
   getData();
   }   });
   }

解决方案 »

  1.   


    补充: 请查看官方实例, 编辑器内容并不是 value. 
      

  2.   

    我之前用过FCK富文本编辑器,就是这么写的
      

  3.   

    服务器断控件的ID在前台并不一定是相同的所以可以使用 <%= FCKeditor1.ClientID %> 来获取编辑器的客户端 ID.
      

  4.   

    你用 ajax 提交 为什么要用服务器端控件呢, 我感到灰常费解.
      

  5.   

     function replyData(id,<%= FCKeditor1.ClientID %>) 这样?
    那value值怎么获取呢
      

  6.   

    我没用过 FCKeditor 只有过他 后面的版本 CKEditor 编辑器都会提供官方方法的. 
    不过 CKEditor 也被我抛弃了 最近换了新的. 我在网上帮你看了一下 . 大概是这样.   var checkContent =FCKeditorAPI.GetInstance("editor");//获取实例
       alert(checkContent.GetXHTML());//获取当前内容 http://goldtoad.iteye.com/blog/507287 摘自
      

  7.   

    var checkContent = FCKeditorAPI.GetInstance("editor");ID 部分 可能需要用 客户端控件获取 某些时候是不需要的.