ASP.NET中AJAX的异步加载(Demo演示)

这篇文章主要介绍了ASP.NET中AJAX的异步加载(Demo演示),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

此次的Demo是一个页面,页面上有两行字,然后后面用AJAX,使用一个下拉框去替换第一行文字[/code]

第一个是被替换的网页

    

这里显示部门信息

这里显示部门信息结束了

第二个是一个类

 using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace WebApplication2 { public class Dept { public int Id { get; set; } public string DeptName { get; set; } } }

然后是一个一般处理程序

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Web; namespace WebApplication2 { ///  /// DeptHandler 的摘要说明 ///  public class DeptHandler : IHttpHandler { public void ProcessRequest(HttpContext context) { //这里的AJAX进行了三秒的延迟 Thread.Sleep(3000); List depts = new List { new Dept(){Id=1,DeptName="财务部"}, new Dept(){Id=2,DeptName="研发部"}, new Dept(){Id=3,DeptName="市场部"} }; StringBuilder sb = new StringBuilder(); sb.AppendLine(""); context.Response.ContentType = "text/plain"; context.Response.Write(sb); } public bool IsReusable { get { return false; } } } }

效果图

AJAX有三秒的延迟加载

前三秒

后三秒

以上就是ASP.NET中AJAX的异步加载(Demo演示)的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » ASP编程