实用的Web进度条


1.建立进度条html页面progressbar.htm
ExpandedBlockStart.gif ContractedBlock.gif < script  language ="javascript" >  

function setPgb(pgbID, pgbValue) 
ExpandedSubBlockStart.gifContractedSubBlock.gif

    
if ( pgbValue <= 100 ) 
ExpandedSubBlockStart.gifContractedSubBlock.gif    

        
//debugger;
        if (lblObj = document.getElementById(pgbID+'_label')) 
ExpandedSubBlockStart.gifContractedSubBlock.gif        

            lblObj.innerHTML 
= pgbValue + '%'; // change the label value 
        }
 
        
if ( pgbObj = document.getElementById(pgbID) ) 
ExpandedSubBlockStart.gifContractedSubBlock.gif        

            
var divChild = pgbObj.children[0]; 
            pgbObj.children[
0].style.width = pgbValue + "%"
        }
 
        window.status 
= "数据读取" + pgbValue + "%,请稍候"
    }
 
    
if ( pgbValue == 100 ) 
ExpandedSubBlockStart.gifContractedSubBlock.gif    
{
        window.status 
= "数据读取已经完成"
        proBar.style.display
="none";
        Table1.style.display
="none";
    }

}
 

</ script >
< html >
    
< head >
        
< link  rel ="stylesheet"  type ="text/css"  href ="common.css"  />
    
</ head >
    
< body  topmargin ="0"  leftmargin ="0" >
        
< table  width ="100%"  height ="100%"  ID ="Table1"  runat =server >
            
< 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 >
2.建立样式common.css
ExpandedBlockStart.gif ContractedBlock.gif .bi-loading-status  { 
ExpandedSubBlockStart.gifContractedSubBlock.gif
/*position: absolute;*/ 
width
: 150px; 
padding
: 1px; 
overflow
: hidden; 
}
 
ExpandedBlockStart.gifContractedBlock.gif.bi-loading-status .text 
{ 
white-space
: nowrap; 
overflow
: hidden; 
width
: 100%; 
text-overflow
: ellipsis; 
padding
: 1px; 
}
 
ExpandedBlockStart.gifContractedBlock.gif.bi-loading-status .progress-bar 
{ 
border
: 1px solid ThreeDShadow; 
background
: window; 
height
: 10px; 
width
: 100%; 
padding
: 1px; 
overflow
: hidden; 
}
 
ExpandedBlockStart.gifContractedBlock.gif.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); 
}
 
3.建立测试页面
3.1html代码
< HTML >
    
< HEAD >
        
< title > progressbar </ 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" >
    
</ HEAD >
    
< body  MS_POSITIONING ="GridLayout" >
        
< form  id ="Form1"  method ="post"  runat ="server" >             
            
<% = fixedHeader() %>
        
</ form >
    
</ body >
</ HTML >
3.2cs代码
首先using
using  System.Threading;
using  System.IO;
using  System.Text;
然后添加代码
public  class  progressbar : System.Web.UI.Page
ExpandedBlockStart.gifContractedBlock.gif    
{
ContractedSubBlock.gifExpandedSubBlockStart.gif        
Page_Load Page_Load
        
private void Page_Load(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
            
if(!Page.IsPostBack)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
{
                
string strFileName =Server.MapPath("progressbar.htm" ); 
                StreamReader sr 
= new StreamReader( strFileName, System.Text.Encoding.Default ); 
                
string strHtml = sr.ReadToEnd(); 
                Response.Write( strHtml ); 
                sr.Close(); 
                Response.Flush(); 
                Thread thread 
= new Thread(new ThreadStart(ThreadProc)); 
                thread.Start(); 
                LoadData();
//load数据 
                thread.Join();
            }

        }

        
#endregion


ContractedSubBlock.gifExpandedSubBlockStart.gif        
fixedHeader  fixedHeader
        
protected  string  fixedHeader()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{    
            StringBuilder s
=new StringBuilder();
            s.Append(
@"<table width='100%' border='1' cellspacing='0' style='MARGIN-TOP:-2px'>");
            s.Append(
@"<TR class='fixedHeaderTr' style='BACKGROUND:navy;COLOR:white'>");
            s.Append(
@"<TD nowrap>Header A</TD>");
            s.Append(
@"<TD nowrap>Header B</TD>");
            s.Append(
@"<TD nowrap>Header C</TD>");
            s.Append(
@"</TR>");
            
for(int m=0;m<100;m++)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
{
                s.Append(
@"<TR>");
                s.Append(
@"<TD>A").Append(m).Append("</TD>");
                s.Append(
@"<TD>B").Append(m).Append("</TD>");
                s.Append(
@"<TD>C").Append(m).Append("</TD>");
                s.Append(
@"</TR>");
            }
            
            s.Append(
@"</table>");            
            
return s.ToString();            
        }

        
#endregion

ContractedSubBlock.gifExpandedSubBlockStart.gif        
ThreadProc  ThreadProc
        
private  void  ThreadProc() 
ExpandedSubBlockStart.gifContractedSubBlock.gif        

            
string strScript = "<script>setPgb('pgbMain','{0}');</script>"
            
for ( int i = 0; i <= 100; i++ ) 
ExpandedSubBlockStart.gifContractedSubBlock.gif            

                System.Threading.Thread.Sleep(
10); 
                Response.Write( 
string.Format( strScript, i)); 
                Response.Flush(); 
            }
 
        }

        
#endregion

ContractedSubBlock.gifExpandedSubBlockStart.gif        
LoadData  LoadData
        
private  void  LoadData()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
            
for(int m=0;m<90000;m++)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
{
                
for(int i=0;i<90000;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
{
                
                }
 
            }
 
        }

        
#endregion

ContractedSubBlock.gifExpandedSubBlockStart.gif        
Web Form Designer generated code  Web Form Designer generated code
        
override  protected  void  OnInit(EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
            
//
            
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
            
//
            InitializeComponent();
            
base.OnInit(e);
        }

        
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/// <summary>
        
/// Required method for Designer support - do not modify
        
/// the contents of this method with the code editor.
        
/// </summary>

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

        
#endregion
    }

转载于:https://www.cnblogs.com/gllgsoft/archive/2008/08/29/1279464.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值