ASPNET實現進度條_第1頁
ASPNET實現進度條_第2頁
ASPNET實現進度條_第3頁
全文預覽已結束

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、ASP.NET實現進度條在網上查閱了很多相關資料,參照對比一番后自己整理了一下,做了個小例子。能夠實現根據后臺數據加載的進度在前臺動態更新進度條、進度條在頁面居中顯示、在進度條內顯示百分比,完成進度后隱藏進度條。個人感覺還是有一定的參考價值,貼出來先。建立一個WEB工程,添加新項->HTML頁面,命名為ProgressBar.htm,內容如下:<!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Transitional/EN" "http:/www.

2、/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="/1999/xhtml" id="mainWindow"><head>    <title>無標題頁</title>    <script language="javascript"> 

3、0;      function SetPorgressBar(pos)                    /設置進度條居中            var screenHeight =&

4、#160;window"mainWindow".offsetHeight;            var screenWidth = window"mainWindow".offsetWidth;            ProgressBarSide.style.width =&

5、#160;Math.round(screenWidth / 2);            ProgressBarSide.style.left = Math.round(screenWidth / 4);            ProgressBarSide.style.top =

6、0;Math.round(screenHeight / 2);            ProgressBarSide.style.height = "21px"            ProgressBarSide.style.display = ""

7、0;                        /設置進度條百分比                        &

8、#160;          ProgressBar.style.width = pos + "%"            ProgressText.innerHTML = pos + "%"     

9、0;          /完成后隱藏進度條        function SetCompleted()                         

10、60; ProgressBarSide.style.display = "none"             </script>  </head>    <body>    <div id="ProgressBarSide" style=

11、"position:absolute;height:21x;width:100px;color:Silver;border-width:1px;border-style:Solid;display:none">        <div id="ProgressBar" style="position:absolute;height:21px;width:0%;background-color:#3366FF"><

12、/div>        <div id="ProgressText" style="position:absolute;height:21px;width:100%;text-align:center"></div>    </div>    </body></html>后臺代碼,Default.aspx.cs

13、:using System;using System.Data;using System.Configuration;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.Threading

14、;using System.IO;public partial class _Default : System.Web.UI.Page     private void beginProgress()            /根據ProgressBar.htm顯示進度條界面      &#

15、160; string templateFileName = Path.Combine(Server.MapPath("."), "ProgressBar.htm");        StreamReader reader = new StreamReader(templateFileName,System.Text.Encoding.GetEncoding("GB2312&q

16、uot;);        string html = reader.ReadToEnd();        reader.Close();        Response.Write(html);        Response.Flush();&

17、#160;       private void setProgress(int percent)            string jsBlock = "<script>SetPorgressBar('" + percent.ToString() + "&

18、#39;); </script>"        Response.Write(jsBlock);        Response.Flush();        private void finishProgress()       &

19、#160;    string jsBlock = "<script>SetCompleted();</script>"        Response.Write(jsBlock);        Response.Flush();        private void Page_Load(object sender, System.EventArgs e)           &#

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論