Click here to Skip to main content
12,401,189 members (39,701 online)
Rate this:
 
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 11-Jan-13 23:01pm
   
Use Ajax
Sandeep Mewara 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 12-Jan-13 0:42am
   
Disable postback and use update panel
navnit.88 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160721.1 | Last Updated 13 Jan 2013
Copyright © CodeProject, 1999-2016
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