VB.NET进度条的方法代码
程序员文章站
2024-03-03 16:49:16
1.创建进度条:复制代码 代码如下:
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
复制代码 代码如下:
<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
上一篇: ASP.NET加密口令的方法实例