本文介绍了每隔x秒在ascx中重新加载TreeView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带树视图的ascx,我需要每10秒重新加载一次树以检查新节点。为此,我添加了一个带有计时器的更新面板来更新树视图。
Enterprise.ascx
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>
Enterprise.ascx.cs中的事件
And the event in Enterprise.ascx.cs
Protected void Timer1_Tick(object sender, EventArgs e)
{
this.UpdatePanel1.Update();
}
这不是更新树视图。这是正确的刷新方式吗?如何检查Timer是否每隔10秒调用一次事件?
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?
推荐答案
<asp:UpdatePanel runat="server" id="UpdatePanel1" UpdateMode="always">
试试这个
try this
这篇关于每隔x秒在ascx中重新加载TreeView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!