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:

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

... (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:


... 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,


10 Years
Discussion Span
Last Post by SheSaidImaPregy

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.