之前沒用過Ueditor去異步提交,最近項(xiàng)目需要用到這個,就下了個來用,結(jié)果可能沒仔細(xì)去看Ueditor的相關(guān)介紹文檔,然后自己也郁悶了一下才把它弄出來,現(xiàn)在可以實(shí)現(xiàn)異步提交了,松口氣,把代碼貼出來,以備參考!如果哪里寫得不好,請幫我指出來哦,謝謝!
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" ValidateRequest="false"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">
<title></title>
<scrjavascript" src="ueditor/editor_all_min.js"></script> <script type="text/Javascript" src="ueditor/editor_config.js"></script> <link rel="Stylesheet" href="ueditor/themes/default/ueditor.CSS" /> <script type="text/javascript" src="../Scripts/jquery-1.4.1.min.js"></script>
</head>
<body>
<script type="text/javascript">
var editor = new UE.ui.Editor();//實(shí)例
editor.render('myeditor');//渲染編輯器
$(function () {
$("#btn").click(
function () {
var nn = editor.getContent();
editor.sync();//這一句至關(guān)重要,沒有它,甭想異步提交了
{
url: "Handler1.ashx",
type: "post",
data: "wenben=" + nn,
success: function (data) {
alert(data);
}
}
);
});
});
</script>
<textarea name="mycontent" rows="" cols="" id="myeditor"> </textarea>
<input type="button" id="btn" />
</body>
</html>
------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------
Handler1.ashx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace WebApplication2.CommunityAdmin
{
/// <summary>
/// Handler1 的摘要說明
/// </summary>
public class Handler1 : IHttpHandler
{
context.Response.Write(context.Request["wenben"]);//這個標(biāo)紅色的地方要注意不要寫錯!
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
轉(zhuǎn)載請保留出處:http://m.survivalescaperooms.com/QMM2008/p/3532929.html