您现在的位置是:网站首页> 编程资料编程资料
ASP.NET中AJAX的异步加载(Demo演示)_实用技巧_
2023-05-24
411人已围观
简介 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演示)的文章就介绍到这了,更多相关ASP.NET中AJAX异步加载内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!
您可能感兴趣的文章:
相关内容
- ASP.NET通过更改Url进行页面传值的实现代码_实用技巧_
- 不可或缺的ASP.NET内置对象小结_实用技巧_
- VisualStudio2019中为.NET Core WinForm App启用窗体设计器_实用技巧_
- 在.NET Core中用最原生的方式读取Nacos的配置方法(推荐)_实用技巧_
- IdentityServer4 QuckStart 授权与自定义Claims的问题_实用技巧_
- ASP.NET Core中的Action的返回值类型实现_实用技巧_
- 详解ASP.NET Core中配置监听URLs的五种方式_实用技巧_
- ASP.NET Core 应用程序中的静态文件中间件的实现_实用技巧_
- ASP.net中Core自定义View查找位置的实例代码_实用技巧_
- 详解在.net core中完美解决多租户分库分表的问题_实用技巧_
