<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ASPxLoadingPanel.aspx.cs" Inherits="ASPxLoadingPanel" %>

<!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 src="Scripts/jquery-1.6.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {

            $("#CheckBox1").click(function () {

                if ($("#CheckBox1").attr("checked")) {
                    //alert("选中了");
                    //$("#LoadingPanel2").attr("ContainerElementID", "divLoad");
                } else {
                    //alert("很遗憾");
                    //$("#LoadingPanel2").attr("ContainerElementID", ""); 好像这样不行

                }
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <dx:ASPxLoadingPanel ID="ASPxLoadingPanel2" runat="server" 
            ClientInstanceName="LoadingPanel2" Text="加载中..." 
            SpriteImageUrl="~/imgs/load.gif" Theme="Mulberry" >
          
        </dx:ASPxLoadingPanel>
        <!--
            ContainerElementID 设置关联那个控件(当然还可以显示图片等信息)
        -->
    
    <div style="height: 74px; background-color: #00FFFF;" id="divLoad">  
    </div>
    <dx:ASPxButton ID="ASPxButton1" runat="server" Text="显示Loading" AutoPostBack="false" 
            oncustomjsproperties="ASPxButton1_CustomJSProperties">
        <ClientSideEvents Click="function(s, e) {
            
                 LoadingPanel2.Show();


            }" />
    </dx:ASPxButton>
        <br />
    <dx:ASPxButton ID="ASPxButton2" runat="server" Text="停止Loading" AutoPostBack="False" 
            oncustomjsproperties="ASPxButton1_CustomJSProperties">
        <ClientSideEvents Click="function(s, e) {
            
                 LoadingPanel2.Hide();


            }" />
    </dx:ASPxButton>
    <br />
    <asp:CheckBox ID="CheckBox1" runat="server" Text="Container"  ClientIDMode="Static" />
      
    <!--
    总结:
        LoadingPanel控件用于在回调服务器时在页面上展示的一个提示控件。
        可通过 LoadPanel.Show()进行展示。
        默认情况下,LoadingPanle是显示在网页正中的,如果更新的只是一个
        局部的Panle或Div,则可以指定LoadingPanel的ContainerElementID,
        显示时会在指定Control的上方。如
            ASPxLoadingPanel1.ContainerElementID = "divLoad";

    -->
    </div>
    </form>
    <p>
        ASPxLoadingPanel在前台可以用客户端名.Show().Hide()两个方法来显示隐藏,有没有在服务器端可以执行的方法或属性来显示隐藏</p>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ASPxLoadingPanel : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void ASPxButton1_Click(object sender, EventArgs e)
    {
        // 服务器选择回延迟一个调用周期

      
        if (this.CheckBox1.Checked)
            ASPxLoadingPanel2.ContainerElementID = "divLoad";
        else
            ASPxLoadingPanel2.ContainerElementID = "";
       

    }
    protected void ASPxButton1_CustomJSProperties(object sender, DevExpress.Web.CustomJSPropertiesEventArgs e)
    {

    }
}

 

posted on 2019-01-17 17:13  qqhfeng16  阅读(274)  评论(0编辑  收藏  举报