模拟速度条

首先要准备好一个HTML文件.我的如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script language="javascript">
function setPgb(pgbID, pgbValue)

     if ( pgbValue <= 100 )
     {
         if (lblObj = document.getElementById(pgbID+'_label'))
         {
              lblObj.innerHTML = pgbValue + '%'; // change the label value
         }
         if ( pgbObj = document.getElementById(pgbID) )
        {
              var divChild = pgbObj.children[0];
              pgbObj.children[0].style.width = pgbValue + "%";
         }
        window.status = "数据读取" + pgbValue + "%,请稍候...";
   }

     if ( pgbValue == 100 )
       window.status = "数据读取已经完成";
}
</script>
<html>
    <head>
         <style type="text/css">
         .bi-loading-status {
  /*position:   absolute;*/
  width:        150px;
  padding: 1px;
 overflow: hidden; 
}
.bi-loading-status .text {
  white-space:  nowrap;
  overflow:     hidden;
  width:             100%;
  text-overflow:     ellipsis;
  padding:      1px;
}
.bi-loading-status .progress-bar {
border:       1px solid ThreeDShadow;
background:   window;
 width:        100%;
padding: 1px;
overflow: hidden;
}
.bi-loading-status .progress-bar div {
background:   Highlight;
overflow: hidden;
height:       100%;
 filter:       Alpha(Opacity=0, FinishOpacity=100, Style=1, StartX=0, StartY=0, FinishX=100, FinishY=0);
}
</style>
     </head>
     <body bgColor="buttonface" topmargin="0" leftmargin="0">
          <table width="100%" height="100%" ID="Table1">
           <tr>
                 <td align="center" valign="middle">
                     <DIV class="bi-loading-status" id="proBar" style="DISPLAY: ; LEFT: 425px; TOP: 278px">
                            <DIV class="text" id="pgbMain_label" align="left"></DIV>
                            <DIV class="progress-bar" id="pgbMain" align="left">
                                 <DIV STYLE="WIDTH:10%"></DIV>
                            </DIV>
                       </DIV>
                   </td>
              </tr>
         </table>
     </body>
</html>


以下是代码

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Threading;
public partial class progressbar : System.Web.UI.Page
{
    public void ThreadProc()
    {
        string strScript = "<script>setPgb('pgbMain','{0}');</script>";
        for (int i = 0; i <= 100; i++)
        {
            System.Threading.Thread.Sleep(10);
            Response.Write(string.Format(strScript, i));
            Response.Flush();
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        
            
    }
  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值