Suntears的技术空间
不要笑我,或许文章技术含量不高.但是我拥有自主知识产权
博客园
::
首页
::
新随笔
::
联系
::
订阅
::
管理
posts - 32, comments - 45, trackbacks - 5
公告
昵称:
Suntears
园龄:
5年9个月
粉丝:
0
关注:
0
<
2007年4月
>
日
一
二
三
四
五
六
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
搜索
常用链接
我的随笔
我的评论
我的参与
最新评论
我的标签
最新随笔
1. InputBox函数用法
2. MsgBox用法
3. 【转】我的悲哀——虽然是转载,但同样是我自己的悲哀
4. asp.net中将DataTable根据xslt生成html静态页面,支持分页
5. javascript中keyCode代码对应表(函数实现)
6. asp.net+ajax多线程进度条的实现
7. asp.net进度条的实现(附demo)
8. asp.net进度条的实现(纯个人收藏)
9. 高度获得相关代码
10. c#去除url中的param参数的函数
随笔分类
.Net技术(12)
动态网页技术(6)
个人爱好(5)
基础概念(2)
数据库技术(1)
随笔(5)
随笔档案
2008年6月 (2)
2007年5月 (2)
2007年4月 (7)
2007年3月 (2)
2007年2月 (1)
2006年12月 (2)
2006年11月 (4)
2006年10月 (2)
2006年8月 (4)
2006年7月 (1)
2006年6月 (1)
2006年5月 (4)
最新评论
阅读排行榜
评论排行榜
推荐排行榜
2007年4月24日
asp.net+ajax多线程进度条的实现
最近写进度条写的有点上瘾,这次弄了个ajax的(*^_^*)
由于之前的那篇(
http://www.cnblogs.com/suntears/archive/2007/04/24/724833.html
)已经对前台如何控制图片进行了演示,这次就仅仅做功能模拟。别忘了打开页面的时候加上start参数,这样才可以启动查数程序。
前台代码:
<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
>
<
html
>
<
head
>
<
title
>
ajaxguagedemo
</
title
>
<
meta
name
="GENERATOR"
Content
="Microsoft Visual Studio .NET 7.1"
>
<
meta
name
="CODE_LANGUAGE"
Content
="C#"
>
<
meta
name
=vs_defaultClientScript
content
="JavaScript"
>
<
meta
name
=vs_targetSchema
content
="http://schemas.microsoft.com/intellisense/ie5"
>
<
script
language
=javascript
>
function
returnresponse()
{
urls
=
"
ajaxguagedemo.aspx?guage=1
"
;
var
xmlHttp
=
new
ActiveXObject(
"
Microsoft.XMLHTTP
"
);
xmlHttp.open(
"
GET
"
,urls,
true
);
xmlHttp.onreadystatechange
=
function
()
{
if
(xmlHttp.readyState
==
4
)
{
temp
=
xmlHttp.responseText;
document.getElementById(
"
ddf
"
).innerText
=
temp;
if
(temp
!=
"
100%
"
)
{
returnresponse();
}
}
}
xmlHttp.send(urls);
}
</
script
>
</
head
>
<
body
MS_POSITIONING
="GridLayout"
>
<
form
id
="Form1"
method
="post"
runat
="server"
>
<
input
type
=button
onclick
="returnresponse()"
value
=1111111
>
<
div
id
=ddf
></
div
>
</
form
>
</
body
>
</
html
>
后台代码如下:
using
System;
using
System.Collections;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Web;
using
System.Web.SessionState;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.HtmlControls;
using
System.Threading;
namespace
guagedemo
{
/**/
///
<summary>
///
ajaxguagedemo 的摘要说明。
///
</summary>
public
class
ajaxguagedemo : System.Web.UI.Page
{
static
public
int
percent
=
0
;
//
静态变量,记录百分比
private
void
Page_Load(
object
sender, System.EventArgs e)
{
//
在此处放置用户代码以初始化页面
if
(Request.QueryString[
"
start
"
]
!=
null
)
{
startThread();
//
开始新进程处理查数程序
}
if
(Request.QueryString[
"
guage
"
]
!=
null
)
{
ajaxResponse();
//
响应ajax,返回百分比
}
}
private
void
guage()
{
for
(
int
i
=
0
;i
<
100
;i
++
)
{
percent
++
;
Thread.Sleep(
500
);
}
}
public
void
startThread()
{
System.Threading.Thread thread
=
new
System.Threading.Thread(
new
System.Threading.ThreadStart(guage));
thread.Start();
}
private
void
ajaxResponse()
{
Response.Write(percent.ToString()
+
"
%
"
);
Response.Flush();
Response.Close();
}
Web 窗体设计器生成的代码
#region
Web 窗体设计器生成的代码
override
protected
void
OnInit(EventArgs e)
{
//
//
CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base
.OnInit(e);
}
/**/
///
<summary>
///
设计器支持所需的方法 - 不要使用代码编辑器修改
///
此方法的内容。
///
</summary>
private
void
InitializeComponent()
{
this
.Load
+=
new
System.EventHandler(
this
.Page_Load);
}
#endregion
}
}
很简单,看页面说明足够理解了。
附上Demo
posted @ 2007-04-24 15:10 Suntears 阅读(6348) 评论(13)
编辑
asp.net进度条的实现(附demo)
posted @ 2007-04-24 10:13 Suntears 阅读(4356) 评论(6)
编辑