ajax中 同一页面中 UpdatePanel 区别 更新多个区域的关键 timer使用方法

关键是将updatepanel的 UpdateMode  设置为 UpdateMode ="Conditional"  默认的话是always 所以同一个页面中的不同updatepanel 总不同时更新,觉的十分不爽,我们设置为 UpdateMode ="Conditional" ,即条件更新后,情况就不同了。
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode ="Conditional" >
            
<ContentTemplate>
                
1---<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                
<br />
                
<asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" />
        
<asp:Button ID="Button1" runat="server" Text="Button" />

接下来我们再在我们想要触发更新的updatepanel 中加入

<Triggers ><asp:AsyncPostBackTrigger ControlID ="Button2"  EventName ="Click" /></Triggers>
这样的话呢,点击button时的updatepanel2才更新呦。好的问题解决了,和大家共享吧。

<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode ="Conditional">
            <ContentTemplate>
                2---<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
            </ContentTemplate>
            <Triggers ><asp:AsyncPostBackTrigger ControlID ="Button2"  EventName ="Click" /></Triggers>
        </asp:UpdatePanel>
下面的是使用timer
<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode ="Conditional" >
            
<ContentTemplate>
                
<asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick" Interval="1000" >
                
</asp:Timer>
                
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label><br />
            
</ContentTemplate>
        
</asp:UpdatePanel>
原文地址:https://www.cnblogs.com/ma/p/724440.html