Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET Treeview
I have tree view located in master page. I have hierarchy up to 4th level
category 1
 - inner category 1
    -inner inner category 1
 - inner category 2
 - inner category 3
 
category 2
 
and so on...
On clicking category 1 its child node will be opened.
 
When I click on inner category 2 which link to some page, then that page is executed so tree get refreshed due to post back.
 
But I want to keep that node active, i.e with some distinguish color then other node.
Posted 11-Jan-13 16:05pm
Comments
Kuthuparakkal at 11-Jan-13 23:01pm
   
Use Ajax
Sandeep Mewara at 11-Jan-13 23:04pm
   
Share the code for this:
When I click on inner category 2 which link to some page, then that page is executed so tree get refreshed due to post back.
You need to stop postback on click of the link. OR not get re-render keeping it in an update panel.
Kuthuparakkal at 12-Jan-13 0:42am
   
Disable postback and use update panel
navnit.88 at 12-Jan-13 0:47am
   
ok i will try using update panel thank you for answering

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Keep your TreeView inside an UpdatePanel and also if you are creating the TreeView on Page_Load, keep it inside !IsPostBack check, this will prevent your tree from getting refreshed.
 
For coloring the selected node, you can use "TreeView1.SelectedNodeStyle.ForeColor", other styles can also be set using SelectedNodeStyle property of TreeView.
 
Hope it helps..
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 CPallini 365
1 Sergey Alexandrovich Kryukov 252
2 OriginalGriff 165
3 George Jonsson 159
4 Richard MacCutchan 110
0 OriginalGriff 6,344
1 Sergey Alexandrovich Kryukov 5,860
2 CPallini 5,125
3 George Jonsson 3,559
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 13 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100