Asp tabpanel更新所有标签

时间:2013-08-23 18:49:47

标签: asp.net

我正在开发一个在TabPanel中显示在线用户的网页,我希望每隔X秒更新一次。这部分有效;但是,TabContainer中的所有其他选项卡也会更新,这是我不想要的。以下是在线用户标签的代码

<cc1:TabPanel runat="server" HeaderText="Online Users" ID="TabPanel1">

    <ContentTemplate>        
        <div>
            <div style="position:relative; text-align:left; width:650px; top: 0px; left: 0px;">
                <asp:Label ID="lblUpdate" runat="server" Text="This page refreshed automatically every 10 seconds, or press the update button to the right"></asp:Label>
            </div>
        </div>

        <asp:Timer runat="server" ID="timer1" Interval="10000"></asp:Timer>
        <asp:Timer runat="server" ID="timer2" Interval="9000"></asp:Timer>

        <asp:UpdatePanel runat="server" ID="updateOnlineUsers" UpdateMode="Conditional">

             <Triggers>
                <asp:AsyncPostBackTrigger ControlID="timer1" />
                <asp:AsyncPostBackTrigger ControlID="timer2"  />
            </Triggers>

            <ContentTemplate>  
                <div style="text-align:right; position:relative; top:-20px">
                    <asp:Image style="position:relative; display:none; z-index:1" ID="Image1" runat="server" ImageUrl="../images/reload.gif" />
                    <asp:ImageButton ID="ImageButton1" style="position:relative; z-index:2" runat="server" ImageUrl="../images/reload5.png" />  
                </div>                
                <div>                    
                    <asp:Label ID="lbluserCount" runat="server"></asp:Label>
                </div>
                <div>
                    <asp:Label ID="lblOfflineUsers" runat="server"></asp:Label>
                </div>
                <div>
                    <asp:Label runat="server" ID="lblOnlineUsers">Hi Everybody</asp:Label>
                </div>                    
            </ContentTemplate>
        </asp:UpdatePanel>    
    </ContentTemplate>
    </cc1:TabPanel>

提前致谢!

1 个答案:

答案 0 :(得分:0)

将计时器移出TabPanel。可能你需要在此之后手动从代码隐藏中将定时器注册为AsyncPostbackTriggers。