日期:2014-05-19  浏览次数:20628 次

asp.net 创建上传进度条
请问在asp.net   中Fileupload控件用来上传文件,但是我想做一个进度条,显示现在完成多少了,请问怎么实现啊,谢谢
最好给我一个c#的例子。

------解决方案--------------------
http://www.chinatcm.net.cn/2965.html
------解决方案--------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<title> 无标题页 </title>

<script type= "text/javascript ">
var xmlHttp;
var key;
function createXmlHttpRequest()
{
if(window.ActiveXObject)
xmlHttp=new ActiveXObject( "Microsoft.XMLHTTP ");
else if(window.XmlHttpRequest)
xmlHttp=new XmlHttpRequest();
}
function go()
{
checkDiv();
createXmlHttpRequest();
xmlHttp.onreadystatechange=callback;
xmlHttp.open( "get ", "ProgressBar.aspx?task=create ",true);
xmlHttp.send(null);
}
function callback()
{
if(xmlHttp.readyState==4&&xmlHttp.status==200)
{
setTimeout( "pollServer() ",1000);
}
}
function pollServer()
{
createXmlHttpRequest();
xmlHttp.onreadystatechange=pollCallback;
xmlHttp.open( "get ", "ProgressBar.aspx?task=poll&key= "+key,true);
xmlHttp.send(null);
}
function pollCallback()
{
if(xmlHttp.readyState==4&&xmlHttp.status==200)
{
key++;
var percent=xmlHttp.responseXML.getElementsByTagName( "percent ")[0].firstChild.nodeValue;
var end=loadPercent(percent);
for(var i=1;i <=end;++i)
{
var span=document.getElementById( "block "+i);
span.innerHTML= "&nbsp;&nbsp;&nbsp; ";
span.style.backgroundColor= "gray ";
}
if(end <9)
{
end++;
var span=document.getElementById( "block "+end);
span.innerHTML=percent+ "% ";
setTimeout( "pollServer() ",1000);
}
else
{
document.getElementById( "complete ").innerHTML= "complete ";
document.getElementById( "go ").disabled=false;
}
}
}
function loadPercent(percent)
{
if(percent.length==1)
return 1;
else if(percent.length==2)
return percent.substring(0,1);
return 9;
}
function checkDiv()
{
key=1;
var pb=document.getElementById( "progressBar ");
if(pb.style.visibility== "visible ")
{
clearBar();
document.getElementById( "complete ").innerHTML= " ";
}
else
pb.style.visibility= "visible ";
}
function clearBar()
{
for(var i=1;i <=9;++i)
{
var elem=document.getElementById( "block "+i);