What I want to do is when im in the Post page I want to highlight the category to which it belongs in the treeview...but considering that each post is not in the sitemap file it just looses focus...so how can I set the selected treeview node to be
www.site.com/sports/soccer/europe/ when im on the
www.site.com/post/2342-Zlatan-scores-again page.
Thanks
M
please "mark as answer" if my answer solved the issue.
</div> <div>I have another way of getting it than session...but how do I set the selected node that way...it doesnt work...</div> <div>Can you show me a working example because</div> <div>treeview1.SelectedNode.NavigateUrl = "/sport/soccer/europe/"</div> <div>what
am I doing wrong?</div> <div> </div>
<div>
</div> <div>Handle the SelectedNodeChanged Event of your TreeView to set the selected node.</div> <div> </div> <div>
<div> </div> <div>
<div> </div>
</div> </div>
Please mark the replies as answers if they help or unmark if not.
Feedback to us
but I still get Object not set to a reference of an object...If I remove this line...I have the treeview visible with all categories collapsed and I print the value of the session variable so those two things work so basically it feels like that the tag
Treeview1.SelectedNode.NavigateUrl is not the right attribute to select a node.
is this something you can confirm or am I in the wrong...I really need to fix this...I have built the entire website and have everything working but this minor snag and I cant figure it out...so this is the only thing I have to fix before taking this site
live...
M
please "mark as answer" if my answer solved the issue.
manga75
Member
389 Points
112 Posts
Set treeview SelectedNode programatically
Jan 31, 2012 12:08 AM|LINK
Hi I have a site with a two aspx pages and a masterpage.
masterpage.master
default.aspx
post.aspx
on the masterpage I have a treeview with a list of categories and when a category is selected I get a list of topics with a intro on each post.
URL example category: www.site.com/sports/soccer/europe/
categories can go three-four levels deep and if I click a specific post I get into the post.aspx
URL example post: www.site.com/post/2342-Zlatan-scores-again
What I want to do is when im in the Post page I want to highlight the category to which it belongs in the treeview...but considering that each post is not in the sitemap file it just looses focus...so how can I set the selected treeview node to be www.site.com/sports/soccer/europe/ when im on the www.site.com/post/2342-Zlatan-scores-again page.
Thanks
please "mark as answer" if my answer solved the issue.
Sum8
Contributor
4141 Points
931 Posts
Re: Set treeview SelectedNode programatically
Jan 31, 2012 05:11 AM|LINK
On clicking posts of particular category, get the category of that post and store it into Session variable.
Now, in master page's Page_Load event, get category from Session variable and set the selected node accordingly.
Sumit Pathak
------------------
ThisPost = Helped == True ? "Mark As Answer" : "Elaborate your problem in more details"
manga75
Member
389 Points
112 Posts
Re: Set treeview SelectedNode programatically
Jan 31, 2012 12:08 PM|LINK
I have another way of getting it than session...but how do I set the selected node that way...it doesnt work...
Can you show me a working example because
treeview1.SelectedNode.NavigateUrl = "/sport/soccer/europe/"
what am I doing wrong?
please "mark as answer" if my answer solved the issue.
Sum8
Contributor
4141 Points
931 Posts
Re: Set treeview SelectedNode programatically
Feb 01, 2012 05:53 AM|LINK
No getting exactly what problem you are facing, but may the following links will help you:
http://stackoverflow.com/questions/107150/asp-net-treeview-and-selecting-the-selected-node
http://forums.asp.net/p/1066455/1544380.aspx
http://forums.asp.net/p/1047866/1478500.aspx
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.treeview.selectednode.aspx
Sumit Pathak
------------------
ThisPost = Helped == True ? "Mark As Answer" : "Elaborate your problem in more details"
Frank Jiang ...
All-Star
16006 Points
1728 Posts
Microsoft
Re: Set treeview SelectedNode programatically
Feb 02, 2012 07:01 AM|LINK
Feedback to us
Develop and promote your apps in Windows Store
manga75
Member
389 Points
112 Posts
Re: Set treeview SelectedNode programatically
Feb 16, 2012 10:54 PM|LINK
...
please "mark as answer" if my answer solved the issue.
Sum8
Contributor
4141 Points
931 Posts
Re: Set treeview SelectedNode programatically
Feb 17, 2012 04:23 AM|LINK
Make sure that the TreeView is getting populated before setting the selected node.
Sumit Pathak
------------------
ThisPost = Helped == True ? "Mark As Answer" : "Elaborate your problem in more details"
manga75
Member
389 Points
112 Posts
Re: Set treeview SelectedNode programatically
Feb 19, 2012 08:39 PM|LINK
I tried using a Session variable and put it in page_load doesnt work...am I suposed to use
Treeview1.SelectedNode.NavigateUrl = Session["Category"];
but I still get Object not set to a reference of an object...If I remove this line...I have the treeview visible with all categories collapsed and I print the value of the session variable so those two things work so basically it feels like that the tag Treeview1.SelectedNode.NavigateUrl is not the right attribute to select a node.
is this something you can confirm or am I in the wrong...I really need to fix this...I have built the entire website and have everything working but this minor snag and I cant figure it out...so this is the only thing I have to fix before taking this site live...
please "mark as answer" if my answer solved the issue.
Sum8
Contributor
4141 Points
931 Posts
Re: Set treeview SelectedNode programatically
Feb 20, 2012 05:24 AM|LINK
Refer this link to set the SelectedNode : http://www.dotnetspark.com/kb/1997-set-selected-node-on-treeview-asp-net.aspx
Also, debug the application and before setting the SelectedNode, check whether TreeView is populated or not.
Sumit Pathak
------------------
ThisPost = Helped == True ? "Mark As Answer" : "Elaborate your problem in more details"
manga75
Member
389 Points
112 Posts
Re: Set treeview SelectedNode programatically
Feb 24, 2012 08:47 AM|LINK
Great thanks this article helped...thanks for your help!
please "mark as answer" if my answer solved the issue.