程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> ASP.NET >> ASP.NET基礎 >> VB.NET進度條的方法代碼

VB.NET進度條的方法代碼

編輯:ASP.NET基礎
1.創建進度條:
復制代碼 代碼如下:
<DIV id="Lay1" style="Z-INDEX: 1; LEFT: 1%; VISIBILITY: hidden; WIDTH: 99%; CURSOR: crosshair; POSITION: absolute; TOP: 32px; HEIGHT: 95%; BACKGROUND-COLOR: #ffffff"><FONT face="宋體"></FONT><FONT face="宋體"></FONT><FONT face="宋體"></FONT><FONT face="宋體"></FONT><br>
<b><font color="#800080" size="2">      & nbsp;          正在檢索數據,請稍候...</font></b>
<table align="center">
<tr>
<td>
<div style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: black 1px solid; PADDING-LEFT: 2px; FONT-SIZE: 8pt; PADDING-BOTTOM: 2px; BORDER-LEFT: black 1px solid; PADDING-TOP: 2px; BORDER-BOTTOM: black 1px solid"><span id="progress1"> </span>
<span id="progress2"> </span> <span id="progress3"> </span> <span id="progress4">
 </span> <span id="progress5"> </span> <span id="progress6"> </span>
<span id="progress7"> </span> <span id="progress8"> </span> <span id="progress9">
 </span> <span id="progress10"> </span> <span id="progress11"> </span>
<span id="progress12"> </span> <span id="progress13"> </span><span id="progress14"> </span><span id="progress15"> </span>
</div>
</td>
</tr>
</table>
<script language="javascript">
var progressEnd = 15; // set to number of progress <span>'s.
var progressColor = 'blue'; // set to progress bar color
var progressInterval = 300; // set to time between updates (milli-seconds)
var progressAt = progressEnd;
var progressTimer;
function progress_clear() {
for (var i = 1; i <= progressEnd; i++) document.getElementById('progress'+i).style.backgroundColor = 'transparent';
progressAt = 0;
}
function progress_update() {
progressAt++;
if (progressAt > progressEnd) progress_clear();
else document.getElementById('progress'+progressAt).style.backgroundColor = progressColor;
progressTimer = setTimeout('progress_update()',progressInterval);
}
function progress_stop() {
clearTimeout(progressTimer);
progress_clear();
}
//progress_update(); // start progress bar
</script>
</DIV>

2.設置查詢按鈕屬性
復制代碼 代碼如下:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此處放置初始化頁的用戶代碼
If Not IsPostBack The
but_find.Attributes.Add("onClick", "Lay1.style.visibility='';progress_update();")
End If
End Sub

3.注冊javascript腳本
復制代碼 代碼如下:
Public Sub scriptjdt(ByVal objPage As System.Web.UI.Page, ByVal strValue As String)
Dim jb As String
jb = "<script language='JavaScript'>" + strValue + "</script>"
objPage.RegisterStartupScript("jdt_ok", jb)
End Sub

4.在查詢按鈕單擊事件中調用
復制代碼 代碼如下:
Private Sub but_find_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles but_find.Click
'查詢數據代碼
'----------------
Me.scriptjdt(Me, "Lay1.style.visibility='hidden';progress_stop();") '關閉進度條代碼
End Sub
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved