如何在搜索结果出来之前,让页面显示“等待中。。。”
在當前頁面點擊搜索按紐后,當前頁的button onclick事件會生成一個sql語句,然后轉到查詢結果頁面,由于查詢可能很費時間,客戶要求在這兩個頁面中加入一個提示用戶正在查詢,請等待的頁,
具體的查詢是在查詢結果頁面的Page_Load進行的。
現在的問題是這個中間頁面怎么自動轉向查詢結果頁面,如果在Page_Load里寫,這個中間頁就顯示不出來
有兩種比較中肯的解決方法:
第一種
1。可以做個公用的用戶控件,copy如下代碼,樣式自己定義
<div id='doing' style='Z-INDEX: 12000; LEFT: 0px; WIDTH: 100%; CURSOR: wait; POSITION: absolute; TOP: 0px; HEIGHT: 100%'>
<table width='100%' height='100%' id="Table1">
<tr align='center' valign='middle'>
<td >
<table? id="Table2" class="loading">
<tr align='center' valign='middle'>
<td>Loading...</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<script language="javascript">
function ShowWaiting()
{
document.getElementById('doing').style.visibility = 'visible';
}
function CloseWaiting()
{
document.getElementById('doing').style.visibility = 'hidden';
}
function MyOnload()
{
document.getElementById('doing').style.visibility = 'hidden';
}
if (window.onload == null)
{
window.onload = MyOnload;
}
</script>
2。在頁面中拖入用戶控件
3。在頁面中給button加客戶端click方法,如下
protected void Page_Load(object sender, EventArgs e)
{
??????? this.Button1.Attributes.Add("onclick", "ShowWaiting();");???????
}
第二種
第一個頁面比如first.aspx加入以下js:
<script language="javascript">
??? <!--
var _tt;
function showSending()
{_tt=window.open("processwin.aspx",'uploadfileprocess',"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,top="+dispHeight+",left="+dispWidth+",width=410,height=200",true);??????????
return true;
????????? }
function closewin()
{
?? if (_tt!=null)
?? {
???? _tt.close();
?? }
}
//-->
</script>
<body bgColor="silver" οnunlοad="closewin();">
然后,后臺代碼first.aspx.cs
page_load()時,檢索按鈕加入如下屬性:
btFileUpload.Attributes.Add("onclick","return showSending()");
processwin.aspx頁面就是你要的中間頁了,上面寫上“等待...”
轉載于:https://www.cnblogs.com/yangxiangwu/archive/2006/05/09/395559.html
總結
以上是生活随笔為你收集整理的如何在搜索结果出来之前,让页面显示“等待中。。。”的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 求一个疼爱宝宝的个性签名
- 下一篇: 个性网女生个性签名