Go homepage(回首页)
Upload pictures (上传图片)
Write articles (发文字帖)

The author:(作者)归海一刀
published in(发表于) 2014/3/16 2:52:01
AJAX实例:动态进度条_[AJAX教程]

AJAX实例:动态进度条_[AJAX教程]

















1.建立进度条html页面

progressbar.htm























2.建立样式common.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;
height: 10px;
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);
}
3.建立测试页面
3.1html代码

progressbar







<%=fixedHeader()%>


3.2cs代码
首先usingusing System.Threading;
using System.IO;
using System.Text;然后添加代码
public class progressbar : System.Web.UI.Page
{
Page_Load#region Page_Load
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
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




fixedHeader#region fixedHeader
protected string fixedHeader()
{
StringBuilder s=new StringBuilder();
s.Append(@"");
s.Append(@"");
s.Append(@"Header A");
s.Append(@"Header B");
s.Append(@"Header C");
s.Append(@"");
for(int m=0;m<100;m++)
{
s.Append(@"");
s.Append(@"A").Append(m).Append("");
s.Append(@"B").Append(m).Append("");
s.Append(@"C").Append(m).Append("");
s.Append(@"");
}
s.Append(@"");
return s.ToString();
}
#endregion




ThreadProc#region ThreadProc
private void ThreadProc()
{
string strScript = "";
for ( int i = 0; i <= 100; i++ )
{
System.Threading.Thread.Sleep(10);
Response.Write( string.Format( strScript, i));
Response.Flush();
}
}
#endregion




LoadData#region LoadData
private void LoadData()
{
for(int m=0;m<90000;m++)
{
for(int i=0;i<90000;i++)
{




}
}
}
#endregion




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




/**////


/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}

来源:http://blog.csdn.net/lynnlin1122

























If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)





QQ:154298438
QQ:417480759