CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 11/27/2006 3:34:50 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 12 Views: 104 Favorited: 0 Favorite
13 Items, 1 Pages 1 |< << Go >> >|
mpaterson
Asp.Net User
TreeView Collapse and Expand Dynamically11/27/2006 3:34:50 AM

0

I have been trying for about 3 hours now to figure out how to dynamically expand and collapse treeView nodes.

 The treeView is databinded to a siteMap which looks like this:

 <siteMapNode url ="default.aspx" title ="Home" description ="Home" id="Home">

<siteMapNode url="calendar/view.aspx" title="Calendar" description="View Calendar" id="Calendar">

<siteMapNode url="events/list.aspx" title="Events" description="List Events" id="Events">

<siteMapNode url ="events/manage.aspx" title ="Manage" description ="Manage Events" id="ManageEvents"/>

</siteMapNode>

<siteMapNode url ="reminders/list.aspx" title ="Reminders" description ="List Reminders" id="Reminders">

<siteMapNode url ="reminders/manage.aspx" title ="Manage" description ="Manage Reminders" id="ManageReminders"/>

</siteMapNode>

</siteMapNode>

<siteMapNode url="contacts/list.aspx" title="Contacts" description="List Contacts" id="Contacts">

<siteMapNode url ="contacts/add.aspx" title ="Add" description ="Add Contact" id="AddContacts"/>

<siteMapNode url ="contacts/print.aspx" title ="Print" description ="Print Contacts" id="PrintContacts"/>

<siteMapNode url ="contacts/import.aspx" title ="Import" description ="Import Contacts" id="ImportContacts"/>

<siteMapNode url ="contacts/export.aspx" title ="Export" description ="Export Contacts" id="ExportContacts"/>

</siteMapNode>

<siteMapNode url="links/list.aspx" title ="Links" description ="List Links" id="Links">

<siteMapNode url ="links/manage.aspx" title ="Manage" description ="Manage Links" id="ManageLinks"/>

</siteMapNode>

<siteMapNode url ="files/list.aspx" title ="Files" description ="List Files" id="Files">

<siteMapNode url ="files/manage.aspx" title ="Manage" description ="Manage Files" id="ManageFiles"/>

</siteMapNode>

</siteMapNode>

 

The treeView id="secNavMenu"

Basically I have 2 issues.  The second issue isn't too bad as I can live with it it.  However if I can't figure out the first issue I'm gonna have to manually create <nodes><asp:treeviewnode>.... on each page.

Issue#1 - using the sitemap above I'd like to dynamically collapse all nodes but the selected node.  ie. if I'm on the calendar page I'd like all other nodes to be collapsed.  I'd like to do this via the .aspx.vb pages for each page that I have.  Otherwise I'll have to manually create the treeViews for each page!

Issue#2 - I can't seem to get it so that "Home" isn't the only Root node.  The only way I could work it out so there are no was with all other nodes being children of Home.

 

Obviously I'm very new to asp.net and I would greatly appreciate any help!

 

Thanks,

Michael

 


If everything happens for a reason what is the reason for this error?
ubaid1900
Asp.Net User
Re: TreeView Collapse and Expand Dynamically11/27/2006 11:16:52 PM

0

Protected Sub TreeView1_TreeNodeExpanded(ByVal sender As Object, ByVal e As TreeNodeEventArgs)
 If e.Node.Parent Is Nothing Then
   Return
 End If
 Dim tn As TreeNode = e.Node.Parent
 For Each node As TreeNode In tn.ChildNodes
   If Not (node = e.Node) Then
     node.Collapse
   End If
 Next
End Sub

overriding the expanded event as shown above should resolve your first issue.

Regarding the second issue, I guess with the sitemap datasource, it is not doable. might be possible with other datasources.

Hope it helped. Thanks

ubaid1900
Asp.Net User
Re: TreeView Collapse and Expand Dynamically11/27/2006 11:27:50 PM

0

The above would not work if more than one root so improved a little.

Protected Sub TreeView1_TreeNodeExpanded(ByVal sender As Object, ByVal e As TreeNodeEventArgs)
 If e.Node.Parent Is Nothing Then
   For Each node As TreeNode In (CType(ConversionHelpers.AsWorkaround(sender, GetType(TreeView)), TreeView)).Nodes
     If Not (node = e.Node) Then
       node.Collapse
     End If
   Next
   Return
 End If
 Dim tn As TreeNode = e.Node.Parent
 For Each node As TreeNode In tn.ChildNodes
   If Not (node = e.Node) Then
     node.Collapse
   End If
 Next
End Sub

 

Hope it helped. Thanks

mpaterson
Asp.Net User
Re: TreeView Collapse and Expand Dynamically11/28/2006 12:42:24 AM

0

A few things:

(1)  It says that ConversionHelpers is not declared.  (2) (node=e.node) says "=" is not defined for types 'system.web.ui.webcontrols.treenode.

Also, What is it exactly that you are doing in the code above?  See my questions underlined next to the code.

Protected Sub TreeView1_TreeNodeExpanded(ByVal sender As Object, ByVal e As TreeNodeEventArgs)
 If e.Node.Parent Is Nothing Then If there is no parent node than you'll collapse that node?
   For Each node As TreeNode In (CType(ConversionHelpers.AsWorkaround(sender, GetType(TreeView)), TreeView)).Nodes
     If Not (node = e.Node) Then I'm not sure what this For statement does.  What is the ctype(conversionhelpers.....?
       node.Collapse             what are you looking for in [not(node=e.node)]?
     End If
   Next
   Return
 End If
 Dim tn As TreeNode = e.Node.Parent
 For Each node As TreeNode In tn.ChildNodes
   If Not (node = e.Node) Then
     node.Collapse
   End If
 Next
End Sub

 

Thanks for the help!

Michael


If everything happens for a reason what is the reason for this error?
mpaterson
Asp.Net User
Re: TreeView Collapse and Expand Dynamically11/28/2006 12:45:16 AM

0

Oh, one more thing.  I'm not sure that it is possible using the TreeView but I would like to use the root nodes as primary navigation at the top of the screen and the childNodes as the secondary navigation on the left side of the screen.  When you click on the primary nav node I'd like it to only expand or display the secondary navigation of that node.

Michael


If everything happens for a reason what is the reason for this error?
ubaid1900
Asp.Net User
Re: TreeView Collapse and Expand Dynamically11/28/2006 2:22:03 AM

0

sorry about that I had used the conversion (C# to VB) tool from here http://www.developerfusion.co.uk/utilities/convertcsharptovb.aspx

 

Just replace the older one with

Protected Sub TreeView1_TreeNodeExpanded(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs) Handles TreeView1.TreeNodeExpanded

        If e.Node.Parent Is Nothing Then
            For Each node As TreeNode In (CType(sender, TreeView)).Nodes
                If Not (node.Equals(e.Node)) Then
                    node.Collapse()
                End If
            Next
            Return
        End If

        Dim tn As TreeNode = e.Node.Parent
        For Each node As TreeNode In tn.ChildNodes
            If Not (node.Equals(e.Node)) Then
                node.Collapse()
            End If
        Next

        If (e.Node.Depth = 1) Then

        End If

    End Sub

 

Regarding the new layout. Can you explain a little more of what you are trying to do?

Thanks

        
 

 

ubaid1900
Asp.Net User
Re: TreeView Collapse and Expand Dynamically11/28/2006 2:39:46 AM

0

remove these lines 

If (e.Node.Depth = 1) Then

        End If

mpaterson
Asp.Net User
Re: TreeView Collapse and Expand Dynamically11/28/2006 4:36:34 PM

0

Thanks a lot.  I'll try this out when I get home.

Regarding what I'm trying to do:

I have all primary navigation at the top (Home, Calendar, Contacts, Links, Files)

I'd like to have all sub navigation on the left.  When you click "Home" the entire treeview should display to the left.  However, when you click on "Calendar" only the subnavigation for Calendar should display on the left.  It should be like this for Contacts, Links, Files.... Home is the only primary nav that will list more than just it's own sub navigation.

I can easily do this by manually creating the <asp:treeview> but I would like to figure out a better way to do it using the sitemap.  I would also like to use a master page but I am having some difficulty getting the pages to display correctly but I'll figure that out later.

Michael


If everything happens for a reason what is the reason for this error?
ubaid1900
Asp.Net User
Re: TreeView Collapse and Expand Dynamically11/28/2006 4:50:24 PM

0

For this purpose you can use the menu control instead with horizontal alignment. In fact I am currently using it in the present project. I am not sure we can do it with TreeView (at least the name sounds like tree).

Thanks.

mpaterson
Asp.Net User
Re: TreeView Collapse and Expand Dynamically11/28/2006 7:56:03 PM

0

I am using the menu control with horizontal orientation for the primary (top) navigation.  However, I didn't see how using the menu control would do what I was looking for in regards to the secondary (left side) navigation.
If everything happens for a reason what is the reason for this error?
ubaid1900
Asp.Net User
Re: TreeView Collapse and Expand Dynamically11/28/2006 8:33:58 PM

0

oh I just had the top thing in mind and forgot about the left only options. Sorry.
ramawithuever
Asp.Net User
Re: TreeView Collapse and Expand Dynamically7/4/2007 8:41:53 AM

0

i m retrieving the nodes from database.How to give the url to that nodes

ramawithuever
Asp.Net User
Re: TreeView Collapse and Expand Dynamically7/4/2007 8:45:40 AM

0

ramawithuever:

i m retrieving the nodes from database.How to give the url to that nodes

to click the menustrip control automatically click to treeview control also

13 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Visual Web Developer 2005 Express Edition For Dummies Authors: Alan Simpson, Pages: 358, Published: 2005
Pro ASP.NET 2.0 in C# 2005 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1255, Published: 2005
Pro ASP.NET 2.0 in VB 2005: special edition. Authors: Laurence Moroney, Matthew MacDonald, Pages: 1360, Published: 2006
Beginning ASP.NET 2.0 Authors: Chris Hart, John Kauffman, Chris Ullman, David Sussman, Pages: 759, Published: 2005
Pro ASP.NET 2.0 in C# 2005: Create Next-generation Web Applications with the Latest Version of Microsoft's Revolutionary Technology Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1426, Published: 2006
Macromedia Dreamweaver MX Advanced for Windows and Macintosh: Visual Quickpro Guide Authors: J. Tarin Towers, Abie Hadjitarkhani, Sasha Magee, Pages: 490, Published: 2002
Windows Forms in Action: Second Edition of Windows Forms Programming with C# Authors: Erik E. Brown, Pages: 803, Published: 2006
Think Microsoft.NET Authors: Bart A. DePetrillo, Pages: 176, Published: 2001
Applications of Graph Transformations with Industrial Relevance: Second International Workshop, AGTIVE 2003, Charlottesville, VA, USA, September 27-October 1, 2003 ; Revised Selected and Invited Papers Authors: John L. Pfaltz, Manfred Nagl, Boris Böhlen, Pages: 500, Published: 2003
ASP.NET 2.0: A Developer's Notebook Authors: Wei Meng Lee, Pages: 326, Published: 2005

Web:
TreeView Collapse and Expand Dynamically - ASP.NET Forums Re: TreeView Collapse and Expand Dynamically. 11-27-2006, 6:16 PM ... Re: TreeView Collapse and Expand Dynamically. 11-27-2006, 6:27 PM ...
Dynamic Drive DHTML Scripts- jQuery TreeView Menu (v1.4) $("#browser").treeview({ add: branches }); });. Demo #3:. Collapse All | Expand All | Toggle All. Item 1. Item 1.0. Item 1.0.0. Item 1.1; Item 1.2 ...
YUI Library Examples: TreeView Control: Dynamically Loading Node Data The first (default) style maintains the expand/collapse icon style even when the node ... Using TreeView with Connection Manager to Dynamically Load Data ...
System and method for dynamically expanding and collapsing a tree ... System and method for dynamically expanding and collapsing a tree view for an HTML ..... sign which can be clicked by users to collapse or expand a branch. ...
obout inc - ASPTreeView - Expand/Collapse levels Example Free ASP Treeview - Incredibly fast. Unlimited nodes. Very easy to use. Lots of features and examples. Cross-browser. - Expand/Collapse levels Example.
Treeview how to expand/collapse treeview nodes by clicking on the parent node? yahoo ui reloading dynamic nodes · tree view target java script ...
Want to get checkbox dynamically on tree view. - microsoft.public ... Subject: Want to get checkbox dynamically on tree view. ... I am having a tree view control with expand and collapse button(by ...
:(: Php Mysql Treeview Tree View Structure Hierarchy Hierarchical ... Php Mysql Treeview Tree View Structure Hierarchy Hierarchical Dynamic Phptreeview ... Hierarchical Dynamic Protect Circular Reference Expand Collapse Select ...
Multilevel Expand-Collapse Content 1.0 - This script allows ... Of course some of them use DHTML to expand new nodes dynamically. ... Auto lookup of item in treeview upon dropdown- Auto collapse or expand possible of ...
vc mfc Want to get checkbox dynamically on tree view. Want to get checkbox dynamically on tree view. - Hitz. 06-Mar-08 07:22:17. I am having a tree view control with expand and collapse ...






problem with content place holder !!?

multiple staticsitemapproviders

menu arrow colour

accessing a webresource from a .skin file

masterpage + dropdownlists + state

asp sitemap

asp.net 2.0 themes - .skin or .css or both

masterpage to content events in a frameset

frame set in masterpage

theme is not applied to a generated page

setting focus on a button and a textbox

vertically centering text in menuitem, how?

masterpages: stretch content to fill height of the page

custom site map provider & resource key

asp.net 2.0 treeview control

themes not being applied

menu control not applying horizontalpadding

dynamically load in stylesheets at runtime

masterpage

getting navigateurl from the menu control

horizontal menu control

creating a tab menu using "menu control and web.sitemap

accessing label value using javascript and then manipulating that value

themes

msdn site

setting simple label items in master page

want asp menu control to work onclick instead of mouse over.

how to handle the onmenuitemclick event

masterpage messes up my css

how to use map property in image control inasp.net 2.0

   
  Privacy | Contact Us
All Times Are GMT