日期:2014-05-17 浏览次数:20616 次
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&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 "回复失败"; }