asp.net 显示等待提示,完成后隐藏消失

       原理就是 先设置待显示的提示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>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值