之前用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&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 "回复失败";
}
下面是相关代码: 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 "回复失败";
}
解决方案 »
- 乱码处理
- 如何在button提交了之后页面刷新了还保存select里面的值
- 一篇文章(已生成静态html)内容太长时用1,2,3...把它分成多篇,怎么做?需要用asp程序实现。
- 如何在后台把#252525的字符转换成System.Drawing.Color型呀
- .NET无法创建ActiveX组件-----急,求救啊.....
- 急急急!!Datagrid HyperLinkColumn 显示鼠标事件!!在线结分
- 一个按钮的小问题
- 分不多,就问一个问题:行业网站用什么论坛比较好?
- C# FTP下载文件,文件名带中文的无法下载
- 请问application,session,cookie的用法。
- 记录用户离开时间
- 水晶报表导出excel 文本类型转换为数字类型
<script>
function getEditorHTMLContents(EditorName) {
var oEditor = FCKeditorAPI.GetInstance(EditorName);
var editorHtml = (oEditor.GetXHTML(true)); ;
//alert(editorHtml);
return editorHtml;
}
</script>这里还有一段,取消掉alert注释,将得到一个对话框,但也仅仅得到这么一个对话框,查饿了下数据库,写入的还是一个个空值
FckNewsContent+Id作个标识
var textarea1 = getEditorHTMLContents("FckNewsContent"+id);
这里面的也要换
// alert(EditorName.toString());
var oEditor = FCKeditorAPI.GetInstance(EditorName);
// alert(oEditor);
var editorHtml = (oEditor.GetXHTML(true));
//alert(editorHtml);
return editorHtml;提示上面的代码出错:Microsoft JScript 运行时错误: 无法获取属性“GetXHTML”的值: 对象为 null 或未定义
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&Toolbar=Default' width='700px' height='400px' frameborder='no' scrolling='no'></iframe></div><tr/>";的问题,就是获取不到这句的id,不知道这句的ID是什么
上面是右键FK生成的HTML源码 你可以拼这个--------------
这个你是怎么算出来的呢