为了账号安全,请及时绑定邮箱和手机立即绑定

Ajax UpdateProgress功能演示

标签:
JavaScript


此功能,使用到Ajax技术UpdateProgress来实现层遮罩效果,从下面的Style可以看到两个样式,一个底层和显法层。

5acf07390001405b00110016.jpgStyle <style>
        #progressBackgroundLayer
        {
            position: fixed;
            top: 0px;
            bottom: 0px;
            left: 0px;
            right: 0px;
            overflow: hidden;
            padding: 0;
            margin: 0;
            background-color: #000;
            filter: alpha(opacity=30);
            opacity: 0.5;
            z-index: 1000;
        }
        
        #processMessageLayer
        {
            position: fixed;
            text-align: center;
            width: 15%;
            border: none;
            padding: 5px;
            background-color: #fff;
            vertical-align: middle;
            z-index: 1001;
            top: 20%;
            left: 4%;
        }
    </style>

 

接下来,还再实现一个取消功能:

5acf07390001405b00110016.jpgCancelPostBack <script type="text/JavaScript" language="JavaScript">

        function CancelPostBack() {
            var objMan = Sys.WebForms.PageRequestManager.getInstance();
            if (objMan.get_isInAsyncPostBack())
                objMan.abortPostBack();
        }

    </script>

 

.aspx

页面中写上ScriptManager,UpdatePanel和主角UpdateProgress:

5acf07390001405b00110016.jpgView Code  <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:Button ID="Button1" runat="server" Text="UpdateProgressDemo" 
                onclick="Button1_Click" />
            <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1"
                DisplayAfter="100" DynamicLayout="true">
                <ProgressTemplate>
                    <div id="progressBackgroundLayer">
                    </div>
                    <div id="processMessageLayer">
                        <img class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="Ajax_Load.gif" alt="Progress" align="absmiddle" />
                        Please wait...<br />
                        <input type="button" onclick="CancelPostBack()" value="Cancel" />
                    </div>
                </ProgressTemplate>
            </asp:UpdateProgress>
        </ContentTemplate>
    </asp:UpdatePanel>

 

为了效果,Insus.NET故意在Button1_Click把进行时间写长了一点:

System.Threading.Thread.Sleep(5000);

 

完整代码:

http://download.cnblogs.com/insus/Ajax/UpdateProgressDemo.rar

 

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消