1

I am working on a webpage that displays online users in a TabPanel, and I want to have it update every X amount of seconds. This part works; however, all of the other tabs in the TabContainer will update too, which I do not want. Here is the code for the online user tab

<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>

Thanks in advance!

4

1 回答 1

0

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

于 2013-08-23T18:59:05.960 回答