asp.net+ajax多线程进度条的实现

最近写进度条写的有点上瘾,这次弄了个ajax的(*^_^*)
由于之前的那篇( http://www.cnblogs.com/suntears/archive/2007/04/24/724833.html)已经对前台如何控制图片进行了演示,这次就仅仅做功能模拟。别忘了打开页面的时候加上start参数,这样才可以启动查数程序。

前台代码:

None.gif <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"  >  
None.gif
< html >
None.gif  
< head >
None.gif    
< title > ajaxguagedemo </ title >
None.gif    
< meta  name ="GENERATOR"  Content ="Microsoft Visual Studio .NET 7.1" >
None.gif    
< meta  name ="CODE_LANGUAGE"  Content ="C#" >
None.gif    
< meta  name =vs_defaultClientScript  content ="JavaScript" >
None.gif    
< meta  name =vs_targetSchema  content ="http://schemas.microsoft.com/intellisense/ie5" >
ExpandedBlockStart.gifContractedBlock.gif    
< script  language =javascript  > dot.gif
InBlock.gif
function returnresponse()
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif    urls
="ajaxguagedemo.aspx?guage=1";
InBlock.gif    
var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
InBlock.gif    xmlHttp.open(
"GET",urls,true);
ExpandedSubBlockStart.gifContractedSubBlock.gif    xmlHttp.onreadystatechange
=function()dot.gif{
InBlock.gif        
if(xmlHttp.readyState==4)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            temp
=xmlHttp.responseText;
InBlock.gif            document.getElementById(
"ddf").innerText=temp;
InBlock.gif            
if(temp!="100%")
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif            returnresponse();
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

InBlock.gif    xmlHttp.send(urls);
ExpandedSubBlockEnd.gif}

ExpandedBlockEnd.gif    
</ script >
None.gif  
</ head >
None.gif  
< body  MS_POSITIONING ="GridLayout" >
None.gif    
< form  id ="Form1"  method ="post"  runat ="server" >
None.gif    
< input  type =button  onclick ="returnresponse()"  value =1111111 >
None.gif    
< div  id =ddf ></ div >
None.gif    
</ form >
None.gif  
</ body >
None.gif
</ html >
None.gif

后台代码如下:

None.gif using  System;
None.gif
using  System.Collections;
None.gif
using  System.ComponentModel;
None.gif
using  System.Data;
None.gif
using  System.Drawing;
None.gif
using  System.Web;
None.gif
using  System.Web.SessionState;
None.gif
using  System.Web.UI;
None.gif
using  System.Web.UI.WebControls;
None.gif
using  System.Web.UI.HtmlControls;
None.gif
using  System.Threading;
None.gif
namespace  guagedemo
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
/// ajaxguagedemo 的摘要说明。
ExpandedSubBlockEnd.gif    
/// </summary>

InBlock.gif    public class ajaxguagedemo : System.Web.UI.Page
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
static public int percent=0;//静态变量,记录百分比
InBlock.gif
        private void Page_Load(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
// 在此处放置用户代码以初始化页面
InBlock.gif
            if(Request.QueryString["start"]!=null)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                startThread();
//开始新进程处理查数程序
ExpandedSubBlockEnd.gif
            }

InBlock.gif            
if(Request.QueryString["guage"]!=null)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                ajaxResponse();
//响应ajax,返回百分比
ExpandedSubBlockEnd.gif
            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
private void guage()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
for(int i=0;i<100;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                percent
++;
InBlock.gif                Thread.Sleep(
500);
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
public void startThread()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            System.Threading.Thread thread
=new System.Threading.Thread(new System.Threading.ThreadStart(guage));
InBlock.gif            thread.Start();
ExpandedSubBlockEnd.gif        }

InBlock.gif        
private void ajaxResponse()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Response.Write(percent.ToString()
+"%");
InBlock.gif            Response.Flush();
InBlock.gif            Response.Close();
ExpandedSubBlockEnd.gif        }

InBlock.gif
ContractedSubBlock.gifExpandedSubBlockStart.gif        
Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
InBlock.gif        
override protected void OnInit(EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//
InBlock.gif            
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
InBlock.gif            
//
InBlock.gif
            InitializeComponent();
InBlock.gif            
base.OnInit(e);
ExpandedSubBlockEnd.gif        }

InBlock.gif        
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
InBlock.gif        
/// 此方法的内容。
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        private void InitializeComponent()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{    
InBlock.gif            
this.Load += new System.EventHandler(this.Page_Load);
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif        
#endregion

ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif

很简单,看页面说明足够理解了。
附上Demo

转载于:https://www.cnblogs.com/suntears/archive/2007/04/24/725331.html

1、指数名称:北京大学数字普惠金融指数 2、课题组:本指数北京大学数字金融研究中心蚂蚁科技集团研究院组成的联合课题组负责编制,课题组顾问包括北京大学数字金融研究中心主任黄益平,蚂蚁集团研究院院长李振华。第一期指数2011-2015)课题组成员主要包括:郭峰、孔涛、王靖一、张勋、程志云、阮方圆、孙涛、王芳。第二期到第六期指数(2016-2023)课题组成员主要包括:郭峰、王靖一、程志云、李勇国、王芳。课题组也获得了北京大学蚂蚁集团多位同事的技术支持。 3、指数属性:这套指数包括数字普惠金融指数,以及数字金融覆盖广度数字金融使用深度以及普惠金融数字化程度;此外使用深度指数中还包含支付、信贷、保险、信用、投资、货币基金等业务分类指数;但由于监管公司数据安全审核等方面的原因,2019-2023的信用货币基金分指数,没有对外公布。 4、指数范围:中国内地31个省(直辖市、自治区,简称“省”)、337个地级以上城市(地区、自治州、盟等,简称“城市”),以及约2800个县(县级市、旗、市辖区等,简称“县域”);部分地区数据存在缺失;港澳台地区数据暂未包括。 5、时间跨度:省级城市级指数时间跨度为2011-2023,县域指数时间跨度为2014-2023。 6、地区代码说明:在2011-2023期间,中国部分地区进行了“撤地设市”“县(市)改区”等改革,调整了地区名称行政区划代码,但并不影响本指数统计;本表中城市代码同时保留了20142018两个版本,县域名称行政区划代码则以2014底的代码为准,以方便使用者合并其他经济社会数据进行分析。 7、引用说明:欢迎各界人士使用指数,如有使用本数据,请注明所用数据为“北京大学数字普惠金融指数”;同时烦请按照以下文献引用方式引用我们的成果:郭峰、王靖一、王芳、孔涛、张勋、程志云,《测度中国数字普惠金融发展: 指数编制与空间特征》,《经济学季刊》,2020第19卷第4期,第1401-1418页。 8、指数包括: index_aggregate(数字金融发展总指数), coverage_breadth(数字金融覆盖广度指数,二级维度3-1), usage_depth(数字金融使用深度指数,二级维度3-2), payment(电子支付指数),insurance(网络保险指数), monetary_fund,investment(网络投资指数), credit(网络信贷指数), credit_investigation, digitization_level(普惠金融数字化程度指数,二级维度3-3)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值