473,582 Members | 3,083 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Persisting ASP.NET 2.0 Treeview Controls' State within a Master Page

Hi,

I'm having an issue with the ASP.NET 2.0 Treeview control and persisting
its' state accross requests. My Control is embedded within a master page
and is used for site navigation. My problem is that the user wants to
know which page they are currently on and therefore I need to highlight
the selected node. The problem is I lose state whenever the user selects
a node and is redirected to another page.

Thanks in advance
Nikron
Sep 27 '07 #1
1 3588
Nikron wrote:
Hi,

I'm having an issue with the ASP.NET 2.0 Treeview control and persisting
its' state accross requests. My Control is embedded within a master page
and is used for site navigation. My problem is that the user wants to
know which page they are currently on and therefore I need to highlight
the selected node. The problem is I lose state whenever the user selects
a node and is redirected to another page.

Thanks in advance
Nikron
OK
So I've figured out the problem.

First of all if you use the NavigateURL property when binding the data
to the Treeview it will not raise the OnSelectedNodeC hanged event.
That's part 1 of the problem. Since I am using a master page with the
treeview on it each time a user selects a different node it redirects
them to a different page and therefore loads the master page again and
looses the viewstate of the treeview.

So to combat this I took out the NavigateURL property for each node and
instead performed a Response.Redire ct within the OnSelectedNodeC hanged.
The main issue in this is that the client wanted to see the selected
node highlighted and of course with the issue I am having where the
treeview looses its state it cannot highlight the selected node because
it is being reloaded the whole time.

So what I done inside the OnSelectedNodeC hanged Event (It gets raised
now because the NavigateURL property is not present) is created a
session variable "SelectedNodeVa luePath" and set it equal to the
Treeview.Select edNode.ValuePat h property. Then OnPagePreRender within
the master page I set the selected node to
TreeView.FindNo de(Session["SelectedNodeVa luePath"].ToString()).Se lect().

This solves my problem, except that the value for each node is infact a
url which contains "/" characters. This was causing all sorts of
problems for the FindNode method. Seems that the "/" character is the
default delimiter for the Treeview valuepath fields. So what I had to do
as well was set the PathSeparator=" :" on the Treeview and all worked.

Hope this helps someone and they don't have to waste any of their time.
Nikron
Sep 28 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1371
by: Tomas Vera | last post by:
Here's another goofy thing. I need to persist the state of items added dynamically to a Panel control between round-trips to the server. I have a web form that contains a TreeView and a DropDownList My web form reads the value of the drop down list, runs a query against a database, then presents the results of the query to the user with...
3
2260
by: Stu | last post by:
Hi, I am creating a control in a PlaceHolder like so: Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click Dim ctrl As AcceptOrCancel = CType(Page.LoadControl("controls/AcceptOrCancel.ascx"), AcceptOrCancel) PlaceHolder1.Controls.Add(ctrl)
10
2339
by: p3t3r | last post by:
I have a treeview sourced from a SiteMap. I want to use 2 different CSS styles for the root level nodes. The topmost root node should not have a top border, all the other root nodes should have a top border. Is it possible to have more than 1 style at the same level (parent node) when using a SiteMap? I want it to appear something like...
2
1776
by: damiensawyer | last post by:
Hello all, I'm wondering if someone can help me with an issue. I have a master page that has a treeview control on it (inside an ascx file). Also on the master page I have a content placeholder which contains the various pages of my application. I wish to have the treeview control displayed at all times during the application.
8
12744
by: Matt MacDonald | last post by:
Hi All, I have a form that displays hierarchical categories in a treeview. Ok so far so good. What I was to do is have users be able to select a node in the treeview as part of filling out the form. I only want to allow single selection, so using checkboxes is out of the question. It works as is, but it makes the form very cumbersome if...
1
1569
by: Vincenzo Milazzo | last post by:
Hi, I have a master page with a treeview control on the left. The treeview's nodes are populated ondemand (property Value and NavigateUrl). When I click on the node the property NavigateUrl loads a content page on the right. The problem is that the treeview doesn't save the state and I must click the treeview's nodes again to open the tree....
1
2172
by: lior | last post by:
Hello, I have a treeview control that I use as a menu & navigation control within a master page. The nodes for this control are loaded from a database. Is there any simple method of maintaining the expanded / collapsed
0
2090
by: Homer J. Simpson | last post by:
A few weeks ago I asked for suggestions on how to persist a tree's node state to cookies, without causing postbacks on each click in the tree. I had a single .aspx file, with a row of buttons on top of the screen, and a tree control below (with EnableViewState set to true). I let the user expand/collapse away to his hearts content without...
1
4874
by: =?Utf-8?B?QnJpYW4=?= | last post by:
I have a master page that contains a simple treeview populated using a SiteMapDataSource so the data is static. Here is my problem. When I expand the menu to show the 2nd level treeview items and then click on one to move to the selected page, when the new page is displayed the treeview has reverted back to it's original non-expanded state. ...
0
7886
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8312
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7920
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5685
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3809
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3835
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1413
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.