留言本项目,【回复留言】的相关代码,要求用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();
} });
}
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();
} });
}
解决方案 »
- 新建ASP.NET网站与新建ASP.NET应用程序的不同?
- TextBox获取不到选中ListBox的值?
- bool带个?号是干什么用的
- 开发环境+编译问题
- 如何从一个页面调用另外一个页面的控件呢。
- sqldatareader和DataSet绑定有何不同
- asp.net初学者问一个关于如何在js代码中输出从数据库里读出的数据
- 我发现asp.net可以对D盘的文件进行操作,如何限制它只能在网站内部起作用?
- 什么是哈希表,简单明了的说一下他的功能,用途,怎么使用?谢谢 !一会儿结分
- <*********>刚学ASP.Net有问题想问100分<*********>
- 如何实现新闻摘要功能
- 在gridview里加了下拉框,怎么样传下拉框的值到objectdatasource
补充: 请查看官方实例, 编辑器内容并不是 value.
那value值怎么获取呢
不过 CKEditor 也被我抛弃了 最近换了新的. 我在网上帮你看了一下 . 大概是这样. var checkContent =FCKeditorAPI.GetInstance("editor");//获取实例
alert(checkContent.GetXHTML());//获取当前内容 http://goldtoad.iteye.com/blog/507287 摘自