CodeVerge.Net Beta
Login Idy
Register Password
  Forgot?
   Explore    Item Entry    Profile    Invite   History    Resources   SiteMap  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML




Zone: > newsgroup > asp.net forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 11/24/2005 12:54:59 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 11 Views: 5 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
12 Items, 1 Pages 1 |< << Go >> >|
Davy_C
Asp.Net User
SiteMap bound Treeview collapses on entering new page11/24/2005 12:54:59 PM

0/0

I have a treeview control which is populated from a SiteMapDataSource. All very simple and straightforward. When I click on any of the links however, the page loads with the treeview collapsed. I'm pretty sure it never did this when I was running the framework beta and as far as I know I've changed nothing. This is driving me slowly nuts and I can't find a solution. I just can't fathom why this isn't keeping the view state as I thought this should be standard behaviour when bound to a sitemap.My treeview code's below though it's pretty standard. 

Any help with this is hugely appreciated.

Davy

<asp:TreeView ID="TreeView1"
  Runat="server"
  DataSourceID="SiteMapDataSource1"
  ExpandDepth="1"
  ExpandImageUrl="~/images/plusFolder.gif"
  NoExpandImageUrl="~/images/file.gif"
  CollapseImageUrl="~/images/minusFolder.gif"
  MaxDataBindDepth="3"
  EnableClientScript="true"
  EnableViewState="true">

  <ParentNodeStyle Font-Size="12px" Font-Bold="False" ForeColor="Black">
  </ParentNodeStyle>
  <SelectedNodeStyle BackColor="Gainsboro" Font-Underline="False" ForeColor="Black">
  </SelectedNodeStyle>
  <RootNodeStyle Font-Size="12px" Font-Bold="True" ForeColor="Black">
  </RootNodeStyle>
  <NodeStyle Font-Names="Tahoma" Font-Size="10pt" ForeColor="DimGray">
  </NodeStyle>
  <HoverNodeStyle Font-Underline="False" ForeColor="#5D7B9D">
  </HoverNodeStyle>

</asp:TreeView>

<asp:SiteMapDataSource ID="SiteMapDataSource1" Runat="server" />


IthraelArlet
Asp.Net User
Re: SiteMap bound Treeview collapses on entering new page11/25/2005 12:55:56 AM

0/0

<p>In the final implementation of the TreeView control, by default at least, there is no viewstate information being passed along (except when you click the "+" or "-" and have Client Script disabled). When you click on a link, it's just a standard link (usually to a different page altogether).

<p>Given this, when you click a link it's going to reload the page to the default depth specified in ExpandDepth. In your case, the tree shouldn't be COMPLETELY collapsed, but should be open to one level.

<p>My ideal would be for the tree to be collapsed on load wtih the exception of the path to the current node; this approach may be of value to you as well. This way large TOCs aren't fully expanded but the user still has feedback as to where they are at in the navigation. This behavior can be implemented with a simple function similar to:

<p>void RevealDescendents(TreeNode treeNode) {
<br> if (treeNode == null) return;
<br> treeNode.Expand = true;
<br> if (treeNode.Parent != null)
<br> RevealDescendents(treeNode.Parent);
<br> }

<p>Here you would save the SelectedNode to a TreeNode object, call objTreeView.CollapseAll() and pass this function the SelectedNode so you end up with a "viewstate" that is at least relevent to the current page.

<p>Unfortunately, however, this approach doesn't work with databinding, apparently, <a HREF="/1122525/ShowPost.aspx">as reported in my recent post</a>.
Davy_C
Asp.Net User
Re: SiteMap bound Treeview collapses on entering new page11/25/2005 9:33:34 AM

0/0

Hi Ithrael and thanks for the rapid response. I have to confess to be slightly lost though (I'm very much a newbie here) as to how to implement your solution. I can't seem to make sense of the code at all. Also I'm using VB.NET so C# doesn't make a whole lot of sense to me. Assuming I'm putting the code into my masterpage how do I save the node state and have it called when I enter a new page? Sorry for my complete lack of a clue.

Davy
IthraelArlet
Asp.Net User
Re: SiteMap bound Treeview collapses on entering new page11/25/2005 10:06:49 AM

0/0

Well, that code won't work until I figure out a way to programmatically modify the treeview (it will work if you declaratively add nodes).  Tell you what, though: when I figure that out I'll reply here with the answer and the code in VB (assuming I find an answer). 
Davy_C
Asp.Net User
Re: SiteMap bound Treeview collapses on entering new page11/25/2005 1:23:23 PM

0/0

Thanks again Ithrael. I find it incredible that this worked in the Beta and was then changed in the final release. Every time my users visit a page they're going to have to root down through the treeview to where they were to get the next page, it's madness. I may consider rolling back to Beta 2 framework if I can't get a solution, at least it worked sensibly.
IthraelArlet
Asp.Net User
Re: SiteMap bound Treeview collapses on entering new page11/25/2005 1:59:46 PM

0/0

If your sitemap isn't too large, I'd just remove the ExpandDepth property.  It can be cumbersome if you have a large sitemap but it will at least display the current node (and call it out visually if you give it an appropriate style). 
Davy_C
Asp.Net User
Re: SiteMap bound Treeview collapses on entering new page11/29/2005 10:21:35 AM

0/0

Well I rolled my Framework back to Beta 2 and my treeview maintains it's state perfectly navigating from page to page. I guess we'll stick with Beta 2 until someone at Microsoft fixes this or until we can find a workaround. I still find it insane that they'd change this feature in the final version.
jdixon
Asp.Net User
Re: SiteMap bound Treeview collapses on entering new page11/29/2005 9:55:52 PM

0/0

Actually what we changed was the default for nodes bound to a datasource to be populateOnDemand. If you add a binding:

<DataBindings>

<asp:TreeNodeBinding DataMember="SiteMapNode" NavigateUrlField="Url" TextField="Description" />

</DataBindings>

You will get back to the old behaviour.

The downside is that you do not get PopulateOnDemand (the binding default is false).

For a sitemap hopefully this will not be a problem.

JD


This posting is provided "AS IS" with no warranties, and confers no rights.
We Are Hiring
Lee Dumond
Asp.Net User
Re: SiteMap bound Treeview collapses on entering new page11/30/2005 12:45:32 AM

0/0

THANK YOU THANK YOU THANK YOU... I was tearing out what little hair I had left on this problem.

What I was trying to do was to have the tree be collapsed on a page, with the exception of the path to the current node. I came here looking for the answer, and here it is!

Now, is there any way to make it so that the current node is NOT rendered as a link on a Treeview? Kind of like RenderCurrentNodeAsLink = False for the SiteMapPath. It just seems silly to have a link that brings you to where you already are. Wink [;)]


==================================================
Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we all know you have been helped.
jdixon
Asp.Net User
Re: SiteMap bound Treeview collapses on entering new page11/30/2005 3:55:23 AM

0/0

Hmmm, best hack I can offer is:

<head runat="server"> 
   <style type="text/css"> 
      .foo
      {
         cursor: Default;
         color: black;
      }
   </style>
</
head>
.
.
.

<SelectedNodeStyle CssClass="foo" />

Ick! [+o(]


This posting is provided "AS IS" with no warranties, and confers no rights.
We Are Hiring
Lee Dumond
Asp.Net User
Re: SiteMap bound Treeview collapses on entering new page11/30/2005 5:31:43 AM

0/0

Not bad. Of course, the link is still clickable, but at least cursor:default will prevent the finger from appearing... Big Smile [:D]
==================================================
Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we all know you have been helped.
Davy_C
Asp.Net User
Re: SiteMap bound Treeview collapses on entering new page11/30/2005 11:38:40 AM

0/0

Thanks a million JD, I've got my TreeView working a treat now with the final framework. I'd never have found that out anytime soon by myself. Makes no real sense to me but hey, it's working Smile [:)]

Davy
12 Items, 1 Pages 1 |< << Go >> >|



Search This Site:





Other Resources:
Access Web App from Server IP Address - general_asp.net.installation_and_setup - Web Programming Newsgroups how to set a menu to be selected when the master page posts back? change password problem... sitemap bound treeview collapses on entering new page ...
Data Bound Controls : The Official Microsoft ASP.NET Site ... of a particular ad displaying on a page can be configured using the ... input controls are displayed for the user to enter the values for the new record. ...
.NET ASP Page 167 - Bytes Site Map urgent please : treeview control expand collapse. All messages in the newsgroup. ... How to control enter button on the client PC in ASP.Net. Trouble writing ...
Wicked Code: Three Cures for Common Site Map Ailments ... in a TreeView, you're not posting back; you're navigating to a whole new page. ... is bound to TreeViewXml-SiteMapProvider, which is bound to TreeView.sitemap. ...
.NET ASP Page 76 - Bytes Site Map Maintaining treeview expand collapse status per node? ... using binding tag in DataList (asp.net 2.0) ... Open new browser window on server side button click ...
Chapter 8: Easy Site Navigation ... step is to open the page on which you want to place the Menu or TreeView control. ... When that Web.sitemap file is bound to a navigation Menu control, anonymous ...
ASP Net [Archive] - Page 261 Session Management when launching "New" Window ... Multicolumn tree view control. Expand/Collapse Datagrid. Date format in datagrid ...
Visual Basic Programming: The TreeView Control To place the new Node in a given position in the tree, you must provide the ... the user can click on a Node object to enter Edit mode and indirectly change ...
Web Development with Visual Web Developer 2005 Express Edition and SQL ... ... which is Web.sitemap, and the graphical interface, which is the TreeView control. ... Place a 0 in the Activity ID field when entering a new record. ...
TheMSsForum.com >> Asp >> Archive Page 99 - The Microsoft Software Forum 34473: Expand/Collapse Datagrid. 34474: Multicolumn tree view control ... 34563: SiteMap and Menu behavior on website using host header ...
CodeProject: Custom TreeView Layout in WPF. Free source code and ... I am wondering how do I add a new node to the tree. ... by the lack of common controls such as a calendar combo for entering dates. ...
 
All Times Are GMT