日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

在 Asp.Net Web 應(yīng)用程序中長(zhǎng)時(shí)間裝載頁(yè)面時(shí)顯示進(jìn)度條

 荷露叮咚 2007-05-25
在 Asp.Net Web 應(yīng)用程序中長(zhǎng)時(shí)間裝載頁(yè)面時(shí)顯示進(jìn)度條,雖然是假進(jìn)度條,不能實(shí)時(shí)反映裝載進(jìn)度,但是可以告訴用戶頁(yè)面正在裝載,以免用戶誤以為系統(tǒng)故障或死機(jī)。
  新建一個(gè) Web 項(xiàng)目,添加4個(gè)文件:Default.htm;Progressbar.aspx;Second.aspx;
common.css。
  Default.htm 頁(yè)面有一個(gè)超鏈,點(diǎn)擊之后先裝載 Progressbar.aspx,裝載完之后裝載 Second.aspx,因?yàn)?Second.aspx 模擬大頁(yè)面所以 Page_Load 中主線程掛起 10 秒鐘,其間仍顯示進(jìn)度條頁(yè)面 Progressbar.aspx。


  代碼如下:


Default.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Default</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name=ProgId content=VisualStudio.HTML>
<meta name=Originator content="Microsoft Visual Studio .NET 7.1">
</head>
<body>
 <a href="Progressbar.aspx?U=Second.aspx">進(jìn)入</a>
</body>
</html>


Progressbar.aspx (HTML)
<%@ Page language="c#" Codebehind="Progressbar.aspx.cs" AutoEventWireup="false" Inherits="WebApp.Progressbar" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
 <HEAD>
  <title>進(jìn)度條</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">
  <link rel="stylesheet" type="text/css" href="common.css" />
  <% string strUrl=Request.Params["U"];%>
  <META http-equiv=Refresh content="0;URL= <%=strUrl%> ">
  <script language="javascript">
   var i = 0;
   
   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 = "數(shù)據(jù)讀取" + pgbValue + "%,請(qǐng)稍候...";
    }
     
    if ( pgbValue == 100 )
     window.status = "數(shù)據(jù)讀取已經(jīng)完成";
   }
   
   function showBar()
   {
    setPgb(‘pgbMain‘,i);
    i++;
   }
  </script>
 </HEAD>
 <BODY onload="setInterval(‘showBar()‘,100)">
  <TABLE id="Table1" style="WIDTH: 760px" cellSpacing="0" cellPadding="0" align="center"
   border="0">
   <TR height="400">
    <TD vAlign="middle" align="center">
     <DIV class="bi-loading-status" id="proBar" style="LEFT: 425px; WIDTH: 300px; TOP: 278px; HEIGHT: 44px">
      <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>


Second.aspx(code-behind)
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace WebApp
{
 /// <summary>
 /// Second 的摘要說(shuō)明。
 /// </summary>
 public class Second : System.Web.UI.Page
 {
  private void Page_Load(object sender, System.EventArgs e)
  {
   // 在此處放置用戶代碼以初始化頁(yè)面


   System.Threading.Thread.Sleep(10000);
  }


  #region Web 窗體設(shè)計(jì)器生成的代碼
  override protected void OnInit(EventArgs e)
  {
   //
   // CODEGEN: 該調(diào)用是 ASP.NET Web 窗體設(shè)計(jì)器所必需的。
   //
   InitializeComponent();
   base.OnInit(e);
  }
  
  /// <summary>
  /// 設(shè)計(jì)器支持所需的方法 - 不要使用代碼編輯器修改
  /// 此方法的內(nèi)容。
  /// </summary>
  private void InitializeComponent()
  {   
   this.Load += new System.EventHandler(this.Page_Load);


  }
  #endregion
 }
}


common.css
.bi-loading-status {


  /*position:   absolute;*/

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多