Click here to Skip to main content
15,886,786 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
I have an ascx with a tree view and I need to reload the tree for every 10 seconds to check for new nodes. To do that I added an Update Panel with a timer to update the tree view.

Enterprise.ascx
<table height="100%" cellspacing="0" cellpadding="0" width="100%" border="0"><br />
        <tr><br />
            <td rowspan="3" width="100px"><br />
                    <table id="TreeTable" style="width: 250px; height: 100%" class=""><br />
                    <tr><br />
                        <td style="width: 100%" height="100%"><br />
                            <asp:Timer runat="server" id="Timer1" Interval="10000" OnTick="Timer1_Tick"></asp:Timer><br />
                             <asp:UpdatePanel runat="server" id="UpdatePanel1" UpdateMode="Conditional"><br />
                             <br />
                              <ContentTemplate><br />
                              <br />
                               <asp:Label ID="Label2" runat="server" CssClass="tableHeader" Text="Enterprises"<br />
                                Width="100%" Height="2%" ></asp:Label><br />
                                <div style="overflow: auto; width: 100%; height: 96%"><br />
                                <asp:TreeView ID="EntView" runat="server" Height="95%" ImageSet="BulletedList"<br />
                                    ShowExpandCollapse="False" ShowLines="True" Width="100%" <br />
                                    onselectednodechanged="EntView_SelectedNodeChanged"><br />
                                    <ParentNodeStyle Font-Bold="False" /><br />
                                    <HoverNodeStyle Font-Underline="True" ForeColor="#DDD" /><br />
                                    <SelectedNodeStyle Font-Bold="True" Font-Underline="True" ForeColor="#DDD" /><br />
                                    <RootNodeStyle Font-Bold="True" ForeColor="Black" /><br />
                                    <NodeStyle Font-Names="Verdana" Font-Size="10pt" ForeColor="Black" /><br />
                                </asp:TreeView><br />
                            </div><br />
                            <br />
                            </ContentTemplate><br />
                           </asp:UpdatePanel><br />
                         </td><br />
                    </tr><br />
                </table>

And the event in Enterprise.ascx.cs
C#
Protected void Timer1_Tick(object sender, EventArgs e)
{
 this.UpdatePanel1.Update();
}


This is not updating the Tree view. Is this the correct way of refreshing? How to check whether the Timer is calling the event for every 10 seconds or not?
Posted

 
Share this answer
 
SQL
<asp:UpdatePanel runat="server" id="UpdatePanel1" UpdateMode="always">


try this
 
Share this answer
 
Comments
Member 10557402 29-Jan-14 7:35am    
Tried this, but facing this error:"The Update method can only be called on UpdatePanel with ID 'UpdatePanel1' when UpdateMode is set to Conditional."

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900