Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

A La Carte, Part 2: Build Deep, Flexible Navigation Using Four New Controls : Page 4

In part 1, we looked in depth at ASP.NET's new Menu control. But ASP.NET 2.0 includes a whole family of controls that make it easy to create deep, complex, and highly-professional navigational elements, including a "bread crumb" style control that will keep your visitors oriented.


advertisement
Accessing Site Map Information Programmatically
If you are not using a SiteMapPath control, you can still programmatically access site map information through the Site Map API (found in the System.Web.SiteMap namespace). The following code segment shows how to display site navigation information programmatically:

Figure 13. Changing Orientation: In this screen shot the orientation of the Menu control has been changed to vertical. Compare with the horizontal orientation in Figure 12 to see the difference.

Partial Class MasterPage_master Sub Page_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) _ Handles Me.Load Dim myCurrentNode As SiteMapNode '---Gets the current node myCurrentNode = SiteMap.CurrentNode '---displays the navigational path--- Dim path As String = myCurrentNode.Title While myCurrentNode.ParentNode IsNot Nothing myCurrentNode = myCurrentNode.ParentNode path = " > " & path path = myCurrentNode.Title & path End While Response.Write(path) End Sub End Class

Besides the CurrentNode property, you can also access site information using:
  • SiteMap.CurrentNode.ParentNode
  • SiteMap.CurrentNode.PreviousSibling
  • SiteMap.CurrentNode.RootNode
  • SiteMap.CurrentNode.NextSibling
In this article, you have seen the various new controls in ASP.NET 2.0 that support site navigation. Site navigation is an important feature of user-friendly Web sites. And having a variety of ways to represent the navigation will allow you to choose the one that best fits the content and the user needs of your site. Remember, a Web site with lots of information is useless without a good navigational mechanism to let users find what they need. Be sure to take plenty of time to experiment with these important new controls and think about how best to apply them in your site.





Wei-Meng Lee is a Microsoft .NET MVP and co-founder of Active Developer, a training company specializing in .NET and wireless technologies. He is a frequent speaker and author of numerous books on .NET, XML, and wireless technologies.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap