使用Timer控制两个UpdatePanel中的我有2个UpdatePanel 有1个Timer 
 用Timer执行定时刷新个UpdatePanel1 
但是 Timer却影响了我的两个UpdatePanel2 
当把放在UpdatePanel2里面的控件拖动到UpdatePanel2外部,则没有影响! 
有什么办法使用Timer控制两个UpdatePanel中的一个 
或者一个Timer只是控制一个UpdatePanel中的一个控件(Timer只是给一个Button计时,其他的不影响) 
请叫各位回答! 先谢谢了一个 

解决方案 »

  1.   

    <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
        
        </div>
            <asp:Timer ID="Timer1" runat="server" Interval="5000" OnTick="Timer1_Tick">
            </asp:Timer>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                </ContentTemplate>
                <Triggers>
                 <asp:AsyncPostBackTrigger ControlID="Timer1" />
                </Triggers>
               
            </asp:UpdatePanel>
            <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
                </ContentTemplate>
            </asp:UpdatePanel>
     Label1.Text = "现在时间: " + DateTime.Now.ToLongTimeString();
            Label2.Text = "现在时间: " + DateTime.Now.ToLongTimeString();参考下.........主要就是设置
      

  2.   

    如果Timer是间断性使用,LZ可以让UpdatePanel2里面的控键在Time1可用的时候不可用,timer不可用的时候才可用,其他情况恐怕就只有自己写JS代码实现了
      

  3.   

    yuan74521940 回答的非常正确  关键就是这一句:<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">  把不需要刷新的那个UpdatePanel的UpdateMode设置为:Conditional