Blogs
 
Friday, April 14, 2006

Way back when, I talked about keeping parent tabs highlighted when on a sub-tab page.
This worked fine and dandy for one set of sub-tabs, but what if we wanted sub-tabs under sub-tabs?

 This is what I orignally had coded...

  Dim node As SiteMapNode = SiteMap.CurrentNode
  If Not node Is Nothing 
AndAlso Not node.ParentNode.Equals(node.RootNode)
AndAlso node.ParentNode IsNot Nothing Then For Each item As MenuItem In mnuMenu.Items If item.DataPath = node.ParentNode.Key Then item.Selected = True End If Next End If

Now I just call a procedure to do this recursively...

 

  Private Sub SelectMenuItem(ByVal node As SiteMapNode)
      If node.ParentNode IsNot Nothing AndAlso 
Not node.ParentNode.Equals(node.RootNode) Then For Each item As MenuItem In mnuMenu.Items If item.DataPath = node.ParentNode.Key Then item.Selected = True ' we found an item to select,
' do not need to look any more
Exit Sub End If Next ' have not found a menu item to select yet ' call the process again with a new node SelectMenuItem(node.ParentNode) End If End Sub

 

With this we can now have as many sub-tabs as we want.

One thing to note though... 
I have to include each page in the web.sitemap file for this to work like I want it to.

Cheers

Jason McEvoy
Web Application / Developer



Archive

Recent Entries

Blogs we read


Page 1 Of 1 (1 items)