您的位置:首页 > 编程语言 > ASP

如何在搜索结果出来之前,让页面显示“等待中...” _asp.net技巧

2011-11-24 21:43 603 查看
在当前页面点击搜索按纽后,当前页的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" onunload="closewin();">

然后,后台代码first.aspx.cs

page_load()时,检索按钮加入如下属性:

btFileUpload.Attributes.Add("onclick","return showSending()");

processwin.aspx页面就是你要的中间页了,上面写上“等待...”
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐