ueditor+asp.net异步提交,可以实现了,嘿嘿

王朝学院·作者佚名  2016-08-27
窄屏简体版  字體: 小  |  中  |  大  |  超大  

之前没用过Ueditor去异步提交,最近项目需要用到这个,就下了个来用,结果可能没仔细去看Ueditor的相关介绍文档,然后自己也郁闷了一下才把它弄出来,现在可以实现异步提交了,松口气,把代码贴出来,以备参考!如果哪里写得不好,请帮我指出来哦,谢谢!

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" ValidateRequest="false"

Inherits="Webapplication2.CommunityAdmin.test" %>

<!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>

<script type="text/javascript" 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();//实例

editor.render('myeditor');//渲染编辑器

$(function () {

$("#btn").click(

function () {

var nn = editor.getContent();

editor.sync();//这一句至关重要,没有它,甭想异步提交了

$.Ajax(

{

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

{

public void PRocessRequest(HttpContext context)

{

context.Response.ContentType = "text/plain";

context.Response.Write(context.Request["wenben"]);//这个标红色的地方要注意不要写错!

}

public bool IsReusable

{

get

{

return false;

}

}

}

}

转载请保留出处:http://www.cnblogs.com/QMM2008/p/3532929.html

 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
© 2005- 王朝網路 版權所有 導航