在Web中,怎么做进度条?急!!

japy0312 2004-12-01 11:39:06
在Web中,怎么做进度条?急!!
...全文
370 22 打赏 收藏 转发到动态 举报
写回复
用AI写文章
22 条回复
切换为时间正序
请发表友善的回复…
发表回复
cm1024 2005-02-27
  • 打赏
  • 举报
回复
好!高手!学习,谢谢!

不过有一点不明白:Loading的HTML中为什么那几个界面元素(如等待的GIF图和“页面加载中,请稍待....”的字样以及它们的外框)为什么要用Script脚本来写?我试过了直接也可以的啊。我对脚本不熟,不知是不是这样有其他的好处?
Karl_He 2004-12-07
  • 打赏
  • 举报
回复
我在项目中遇到了同样的情况,也是花了很多时间来找WEB中的进度条.最后采取了以下的方式:先把目标URL传参给loading.aspx页面,让它加载,界面中会显示一个进度条,但不是到了最大值就结束,是一张GIF动画.当在loading.aspx中完全打开目标URL的内容时,该loading.aspx页面消失,目标URL页面显示.

loading.aspx

html:
<%@ Page language="c#" Codebehind="loading.aspx.cs" AutoEventWireup="false" Inherits="MyWebMoney.loading" EnableViewStateMac="false" %>
<HTML>
<HEAD>
<script language="javascript">
function fun(){
if (document.proccess.hid.value !=undefined ){
if (document.proccess.hid.value !="") {
document.location.href = document.proccess.hid.value
}
}
}
</script>
</HEAD>
<body onLoad="fun()" bgcolor="#fffef9">
<div style='MARGIN-TOP:40px;MARGIN-LEFT:40px;MARGIN-RIGHT:0px'>
<p>
</p>
<p align="center">
</p>
<p align="center">
</p>
<p align="center">
</p>
<div style='MARGIN-TOP:-20px;MARGIN-LEFT:0px;MARGIN-RIGHT:0px' align="center" id="loading">
<form method="post" name="proccess">
<input id="hid" type="hidden" runat="server" NAME="hid">
<script language="javascript">
document.write("<br><br><br><br><table border=0 cellspacing=1 cellpadding=0 bgcolor=#000000 ><tr bgcolor=#ffffff><td style='font:9pt Verdana;'>")
document.write("<img src='./IMAGES/loadbar1.gif'border=0>")
document.write("</td></tr></table><br>")
document.write("<div align=center style='font-size:9pt;color:#000000;'>页面加载中,请稍待.....</div>")
</script>
</form>
</div>
</div>
<div align="center"><FONT face="宋体"></FONT>
<script>
<!--
if ((document.proccess.hid.value !=undefined ) && (document.proccess.hid.value !="")) {
if (document.layers)
document.write('<Layer src="' + document.proccess.hid.value + ' " visibility="hide"> </Layer>')
else if (document.all || document.getElementById)
document.write('<iframe src="' + document.proccess.hid.value + '" style="visibility: hidden;"></iframe>')
else
alert("页面加载完毕!")
location.href = document.proccess.hid.value
}
//-->
</script>
</div>
</body>
</HTML>

loading.aspx.cs:
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;

namespace MyWebMoney
{
/// <summary>
/// loading 的摘要说明。
/// </summary>
public class loading : System.Web.UI.Page
{
protected System.Web.UI.HtmlControls.HtmlInputHidden hid;

private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if (!this.IsPostBack)
{
if (this.Request.QueryString["url"] !=null )
{
hid.Value = this.Request.QueryString["url"].ToString();
}
}
}

#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
}
}

如目标url为: index.aspx
则链接可写作: http://localhost/loading.aspx?url=index.aspx
YQShi 2004-12-07
  • 打赏
  • 举报
回复
以前看到过一个,不过连续去读服务器端的数据;对效率有影响
peterlanhaijun 2004-12-07
  • 打赏
  • 举报
回复
也许能行,要自己做一个web进度条控件,有点麻烦呀。
japy0312 2004-12-07
  • 打赏
  • 举报
回复
大家顶呀
跋涉者 2004-12-02
  • 打赏
  • 举报
回复
客户端javascript是单线程,在显示进度条的时候也没做其它什么事情.我想应该是在客户端写一个程序来更新progressbar,其取值由服户端开个线程来提供.
笑容天下事 2004-12-02
  • 打赏
  • 举报
回复
学习中,顶
winsex 2004-12-02
  • 打赏
  • 举报
回复
帮你顶
japy0312 2004-12-02
  • 打赏
  • 举报
回复
大家来顶呀
风轻扬 2004-12-02
  • 打赏
  • 举报
回复
帮你顶
cathylang 2004-12-02
  • 打赏
  • 举报
回复
学习,up
lonelydreamsym 2004-12-02
  • 打赏
  • 举报
回复
不会,up
japy0312 2004-12-02
  • 打赏
  • 举报
回复
怎么没有回答呀???
「已注销」 2004-12-02
  • 打赏
  • 举报
回复
很难,因为web是无状态的
japy0312 2004-12-02
  • 打赏
  • 举报
回复
to noeye(我会用心)
能具体点吗,最好能给我代码看看
flcandclf 2004-12-01
  • 打赏
  • 举报
回复
等找到了告诉你,顺便接分!
japy0312 2004-12-01
  • 打赏
  • 举报
回复
顶者有分
greennetboy 2004-12-01
  • 打赏
  • 举报
回复
http://dotnet.aspx.cc/ShowDetail.aspx?id=794566B9-5EA2-4782-2D42-E133F3C7BA74
japy0312 2004-12-01
  • 打赏
  • 举报
回复
如果有源代码,希望能发给我
japy0516@126.com
japy0312 2004-12-01
  • 打赏
  • 举报
回复
我这里数据批量导入,希望能用进度条显示导入进度,望大家帮帮我呀!!
加载更多回复(2)

110,499

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧