Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Treeview Control
Message
From
01/12/2009 16:53:15
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
Treeview Control
Environment versions
Environment:
ASP.NET
Miscellaneous
Thread ID:
01437169
Message ID:
01437169
Views:
84
Back to trying to learn .NET

In this particular experiment I've built a Master page which has a Treeview control and room for a content page. The Page Load method gets data from a MySql query and builds the Treeview. The Treeview is set up with ExpandDepth = 0.

When the user clicks one of the nodes on the Treeview I want to bring up one of two pages, depending on the text of the parent node. So there are four pages involved: (1) MasterPage (2) DefaultPage - for first time load (3) Page1 - if parent node contains "GOAL" (4) Page2 - all other nodes

The code in the MasterPage looks something like
Imports System.Data
Imports MySql.Data.MySqlClient

Partial Class MasterPage
Inherits System.Web.UI.MasterPage

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  If Not IsPostBack Then
           .
           .
      Build the treeview
        .
        .
   End If
End Sub

Protected Sub TreeView1_SelectedNodeChanged(ByVal sender As TreeView, ByVal e As System.EventArgs) Handles TreeView1.SelectedNodeChanged

   If Not sender.SelectedNode.Parent Is Nothing Then
      If sender.SelectedNode.Parent.Text.ToUpper.Contains(" GOAL") Then
         Response.Redirect("page1.aspx")
      Else
         Response.Redirect("page2.aspx")
      End If
   End If
End Sub
End Class
Starting the system brings up the following events
   DefaultPage Load - Not isPostBack
   MasterPage Load - Not isPostBack
Clicking on one of the "GOAL" items in the treeview brings up the following events
   DefaultPage Load - isPostBack
   MasterPage Load - isPostBack
   Treeview SelectedNodeChanged
   Page1 Load - Not isPostBack
   MasterPage Load - Not isPostBack
The problem for the moment is that the Treeview has been rebuilt and reloaded in its original state (no expansion)

Finally getting to the question................

How can I code the Master Page so that it does not rebuild the treeview each time it moves to Page1 and shows it in the same state as when the item was clicked.

(I assume there is something with the Session object, but my attempts to use it show that I don't understand how ... so I won't show my failed efforts there)

Thanks to all for responses
Next
Reply
Map
View

Click here to load this message in the networking platform