Launch page from Treeview

richlp

Member
Joined
Oct 16, 2009
Messages
9
Programming Experience
10+
Disclaimer: Brand new to this site. My apologies if this is posted in the wrong forum. My apologies also if there is too much extraneous detail in my post. I hope you can read through it, understand my problem, and point me in the right direction.

As part of my learning process for migrating to .NET 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 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("default2.aspx")
Else
Response.Redirect("default.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 here is that the Treeview has been 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, etc?

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

Thanks to all for responses
 
Back
Top