Greetings!

I'm building a web page that in its master file has a treview navigation control. Now, this treeview has a root, a parent and leaf nodes.

I'm having a problem with the post back of this control. Basically, I have set the "parent" nodes not to be exapnded, so the user has to click the parent node to see the leaf nodes below its parent node. For example:

Root
Parent (The user only sees the leaf nodes if he/she clicks this parent node)
Leaf
Leaf
Leaf

... (the same patterns continues)

Well, my problem is that when the user clicks, let's say, the parent node(to see the leaf nodes) and then clicks the "leaf" node #1 in page1.aspx (which has a url to page2.aspx for example), the page2.aspx is loaded but the tree view control is in its original state, which is:

Root
Parent

... and then I have to click again the parent node (in the new page2.aspx) to see the leaf nodes.

Is there a code, or article that someone can provide me to solve this problem, so each time the user clicks a parent node in a page and the leaf nodes are visible, when the user goes to another page this leaf nodes are still visible?

Thanks you,

Eduardo

Recommended Answers

All 3 Replies

You would need to put your current treeviewstate in a session variable to call along every page on the site. Otherwise, it is page to page or every page has a different coding to show the correct tree node (which is impossible in most sites). Here's an example:

http://forums.asp.net/p/1022893/1387445.aspx#1387445

Wow ... thanks a lot for this information. Right now, because of your help, I got this to do what I wanted to achieve. I just need to make some small changes. Now, did you say that this code has to be in every page even though the tree view is in my master page?

Thanks a lot

No, the code only has to be in your master. By storing your current treeview state in a session variable, it can be called from every page instead of having to hard-coding special parameters into every single page.

Use a session variable, it will be accessed across the application, not just in the same page so you won't lose the current nodes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.