为什么ASP.NET TreeView节点扩展不能用于回发?

时间:2015-05-11 18:25:18

标签: asp.net vb.net treeview

我使用数据库中的数据填充ASP.NET(VB)TreeView。填充树时,我会根据数据以编程方式扩展特定节点。在调用非回发时正确完成节点扩展,但在单击按钮后, 用于回发。我认为页面生命周期正在以某种方式重置按钮回发上的格式。有谁知道如何填充TreeView节点,格式完整的按钮回发?

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

  'Formatting intact
    If Not Page.IsPostBack Then
      loadTreeView("MyTree")
    End If

  'Formatting not intact
    If Page.IsPostBack Then
      loadTreeView("MyTree")
    End If


End Sub

'Formatting not intact
Public Sub btnLoadHierarchy_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLoadHierarchy.Click
  loadTreeView("MyTree")
End Sub

<asp:Button ID="btnLoadHierarchy" runat="server" Text="Load Hierarchy"/>

<asp:TreeView ID="HierarchyTree" runat="server">
</asp:TreeView>

0 个答案:

没有答案