原理就是 先设置待显示的提示div隐藏,点击button 响应前台显示div函数,后执行后台的处理任务,待任务处理完后,会自动刷新页面,回到初始隐藏div的界面。
前台:
<span style="font-size:18px;"><%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script language="JavaScript" type="text/JavaScript">
function toggle(targetid) {
if (document.getElementById) {
target = document.getElementById(targetid);
if (target.style.display == "block") {
target.style.display = "none";
} else {
target.style.display = "block";
}
}
}
</script>
<style type="text/css">
#div1{
height:100%;
width:100%;
display:none;
background-color:Gray;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="update2" runat="server" Text="更新"
OnClientClick="toggle('div1')" οnclick="Button_about_Click" Height="45px"
Width="100px"/>
<<span style="color: rgb(255, 0, 0);">div id="div1"</span> class="d1" style="font-size: 35px;z-index:12"> <br /><br /><br />正在更新,请稍后...<p></div>
</div>
</form>
</body>
</html></span>
后台:
<span style="font-size:18px;">protected void Button_about_Click(object sender, EventArgs e)
{
Thread.Sleep(5000);
//this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "dd", "<script>toggle('div1');</script>", true);
System.Web.HttpContext.Current.Response.Write("<script language=javascript> alert('完成')</script>");
}</span>