继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

Ajax UpdateProgress功能演示

慕UI0519722
关注TA
已关注
手记 296
粉丝 85
获赞 267


此功能,使用到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 src="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

 

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP