Treeview control

S

Schoo

I have a treeview control that is working just fine in my ASP.NET app. I am
using the control as a menu for an intranet site for our company. The
problem is that when the user clicks on an item in the tree (say something 2
or 3 levels down), the control will reset (because it is refreshed as a
'server side control') when the new page appears. So, I am interested in
exploring my options to provide the control to the user so their selected
level in the tree is preserved between clicks.

I am familiar with using frames to perform this task, but I have learned to
cringe at the thought of frames in my pages. What other stratagies could I
use?

Scott
 
S

Steven Cheng[MSFT]

Hi Scott,

From your description, you use a TreeView control in your web page. And you
found when you navigate the page (with treeview) away to new page and turn
back, the treeview's display status(expanded nodes) will reset the the
intial status so you're wondering how to remain the states without use
frame based page ,yes?
If my understanding is not quite correct, please feel free to let me know.

Based on my understanding, the TreeView's State infos are stored in
ViewState, so when we add a treeview control on a page. By default, when we
post back the page (click a button on the page or set the TreeNode's select
change as autopostback), after the page return, the TreeView's state will
remain. However, if we only expand or close the node and without post back,
the states will not be stored into viewstate(since these evens all occur at
clientside) so when you refresh the page, it will return to the last state
when postedback. In addition, if we navigate to another new page and turn
back,since the page is initialized again ,the TreeView will of course
return the states which defined in the aspx page source. Do you think so?
IF you have any thing unclear or any other ideas, please feel free to post
here. Thanks.



Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
S

Schoo

Steven,

Thank you for your reply. I'm not sure I understand your response corretly.
It does not appear to offer a solution. I am not clear on what you are
trying to say. Can you please offer an example or be more clear? Thank
you.

Scott
 
S

Steven Cheng[MSFT]

Hi Scott,

Thanks for the followup. In fact, what I mean is just put a
TreeView(autopostback=false) and some buttons on a page, and when we expand
some nodes and click a certain button and post back the page, after the
page return back, the TreeView will remain expanded. This is a normal
behavior since the TreeView will maintain its states in the ViewState. And
if we click one node and redirect to another page and then since the
ViewState is page based, the TreeView on new page will of course display as
inital state. So I'm still a bit wondering on the
=======================
The problem is that when the user clicks on an item in the tree (say
something 2
or 3 levels down), the control will reset (because it is refreshed as a
'server side control') when the new page appears.
=======================
you mentioned, is it one of the above cases I mentioned? Or can you provide
a simple page and the steps to perform the scenario you mentioned? Thanks.


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
S

Steven Cheng[MSFT]

Hi Scott,

Have you had a chance to check out the suggestions in my last reply or have
you got any further ideas on this issue? If you have anything unclear or if
there're anything else we can help, please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
S

Schoo

Steven,

Thanks for your ideas, but the autopostback did not work. I suspect the
reason is because I built the menu as a control on the page and because of
that it kept refreshing.

I ended up just setting up frames and now it is done. Not exactly the best
programming technique, but the job is done and I am moving on. The customer
loves it by the way.

Thanks again.

Scott
 
P

pongkers

i think i know what problem you have. i think you want, that if there is
a postback, your treeview stay's the way is was? well here is what i'm
having

i have a treeview, who controls an catalogue. When a user clicks on a
treenode, there is a postback with the data wich i get from a database!
a the same time, the node where is clicked on, will expand! This is
possible, because i use 'parameter parsing via url'. So every time
there is an pageload i use the following
//////////////////////////////////////////////////////////
protected void ExpandNode(string value)
{

foreach (TreeNode node in TreeViewCatalogus.Nodes)
{
if (node.Value.Equals(value))
{
node.Expand();
}
}
}
///////////////////////////////////////////////////////////

the 'string value' is the Request.QueryString["hc"] which can be found
in the url : http://tinyurl.com/dymak

i hope this is a good solution to your problem!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Treeview node expand/collapse causing IE crash 0
TreeView 5
TreeView Control 0
ASP.Net Treeview in VS.Net 2003 1
Treeview Control 15
treeview control 0
TreeView 0
Exiting infinite loop with keypress in python 1

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,084
Latest member
HansGeorgi

Latest Threads

Top