AJAX中关于多个UpdatePanel 的 UpdateProgress 的使用方法


aspx 代码:
< asp:ScriptManager ID = " ScriptManager1 "  runat = " server " >
                    
</ asp:ScriptManager >
                    
< asp:UpdatePanel ID = " UpdatePanel1 "  runat = " server " >
                        
< ContentTemplate >
                            
< asp:Label ID = " Label1 "  runat = " server "  Text = " 页面初始化 " ></ asp:Label >
                            
< asp:Button ID = " Button1 "  runat = " server "  OnClick = " Button1_Click "  Text = " Button "   />
                            
< asp:UpdateProgress ID = " UpdateProgress1 "  runat = " server "  AssociatedUpdatePanelID = " UpdatePanel1 " >
                                
< ProgressTemplate >
                                    panel1 正在处理数据
                                
</ ProgressTemplate >
                            
</ asp:UpdateProgress >
                        
</ ContentTemplate >
                    
</ asp:UpdatePanel >
                    
< br  />
                      
< br  />
                    
< asp:UpdatePanel ID = " UpdatePanel2 "  runat = " server " >
                        
< ContentTemplate >
                            
< asp:Label ID = " Label2 "  runat = " server "  Text = " 页面初始化 " ></ asp:Label >
                            
< asp:Button ID = " Button2 "  runat = " server "  OnClick = " Button2_Click "  Text = " Button "   />
                            
< asp:UpdateProgress ID = " UpdateProgress2 "  runat = " server "  AssociatedUpdatePanelID = " UpdatePanel2 " >
                                
< ProgressTemplate >
                                    panel2 正在处理数据
                                
</ ProgressTemplate >
                            
</ asp:UpdateProgress >
                        
</ ContentTemplate >
                    
</ asp:UpdatePanel >

aspx.CS 代码:


  
protected   void  Button1_Click( object  sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(
3000 );  // 为人加的 3 秒延时,为了能让UpdateProgress显示出效果

        Label1.Text 
=   " Page refreshed at  "   +

            DateTime.Now.ToString();

    }
    
protected   void  Button2_Click( object  sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(
3000 );

        Label2.Text 
=   " Page refreshed at  "   +

            DateTime.Now.ToString();

    }

关键点:

 <asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel2">

 要为 UpdateProgress  控件指定 AssociatedUpdatePanelID 属性,是要控制哪一个 UpdatePanel 。这样
UpdateProgress   就可以有选择的为某一个UpdatePanel 生效!

你可能感兴趣的:(progress)