1 2 3无标题页 4 27 28 29 33 34
后台代码:
1 Default.aspx.cs: 2 3 using System; 4 using System.Data; 5 using System.Configuration; 6 using System.Web; 7 using System.Web.Security; 8 using System.Web.UI; 9 using System.Web.UI.WebControls;10 using System.Web.UI.WebControls.WebParts;11 using System.Web.UI.HtmlControls;12 using System.Threading;13 using System.IO;14 15 public partial class _Default : System.Web.UI.Page16 {17 private void beginProgress()18 {19 //根据ProgressBar.htm显示进度条界面20 string templateFileName = Path.Combine(Server.MapPath("."), "ProgressBar.htm");21 StreamReader reader = new StreamReader(@templateFileName,System.Text.Encoding.GetEncoding("GB2312"));22 string html = reader.ReadToEnd();23 reader.Close();24 Response.Write(html);25 Response.Flush();26 }27 28 private void setProgress(int percent)29 {30 string jsBlock = "";31 Response.Write(jsBlock);32 Response.Flush();33 }34 35 private void finishProgress()36 {37 string jsBlock = "";38 Response.Write(jsBlock);39 Response.Flush();40 }41 42 private void Page_Load(object sender, System.EventArgs e)43 {44 beginProgress();45 46 for (int i = 1; i <= 100; i++)47 {48 setProgress(i);49 50 //此处用线程休眠代替实际的操作,如加载数据等51 System.Threading.Thread.Sleep(50);52 }53 54 finishProgress();55 }56 }