Great ASP.NET 2.0 Site Navigation Tutorial Series

Scott Mitchell has written a really great tutorial series on the new ASP.NET 2.0 Site Navigation system and features. 

He recently published Part 3 of the series, which discusses the "SecurityTrimming" feature new to ASP.NET 2.0 that allows you to automatically show/hide nodes within the site navigation hierarchy based on the current Authentication and Role status of an incoming user (for example: you could hide portions of a menu automatically if the current user isn't in an "Admin" role).

Part 4 of the series talks about building a custom site map provider.  In case you missed my post from last-month, you might also want to check out Jeff Prosise's cool new SQL Site Map Provider for ASP.NET 2.0 that he built and wrote about (and provided all the source code for you to play with and tweak).  This allows you to store all of your site navigation structure in a database instead of XML files, and uses the new ASP.NET SqlCacheDependency feature to cache in the middle-tier but immediately invalidate when the database changes.

Below is a quick description + link to each part of the Scott Michell's Site Navigation series:

  • Part 1 - shows how to create a simple site map using the default XML-based site map provider and how to display a TreeView and SiteMapPath (breadcrumb).
  • Part 2 - explores programmatically accessing site map data through the SiteMap class; includes a thorough discussion of the SiteMapPath (breadcrumb) control.
  • Part 3 - examines how to use base the site map's contents on the currently logged in user and the authorization rules defined for the pages in the site map.
  • Part 4 - delves into creating a custom site map provider, specifically one that bases the site map on the website's physical, file system structure.

    In case you missed it, I also blogged this tutorial last month that shows creating a master-page + site navigation structure and then using a DataList control to databind to the site-navigation system and use pure CSS to stylize the resulting menu site. 

    I also blogged in December a little about the Control Adapter Architecture in ASP.NET, and how we were planning to build some CSS adapters for the <asp:menu> and <asp:treeview> controls to provide the option to emit unordered lists (<ul><li></ul>) in place of tables for rendering output (something a lot of people have asked for).  We actually have someone working on this now and are planning to ship this as a web download (including source) in the near future. 

    Net Summary: If you haven't checked out the Site Navigation features yet in ASP.NET 2.0 -- you should! :-)

    Hope this helps,

    Scott

     

11 Comments

  • I have been working on the new declaritive model in all these days. There are a huge bunch of articles and tutorials teaching how you can start to programming with it without write one line codes. All fabulous.



    But when I am working on it, I keep having this question which prevents me understanding more what is going on for this datasource control model.



    Do you mind introduce some more articles about how is the datasource control really working during a page cycle. When does it start the data connection and fetch the data combined with

    the gridview bind to this datasource?



    I am still quite confused to understand how the datasource control automatically get the value from web control as its parameter values.







  • How near is that future for the CSS Control Adapter for the menues? Also, why isn't it default ;)

  • Hi Scott,



    I'm delighted to hear about the work to provide navigation controls as unordered lists and CSS - It was quite disappointed when I looked at the emitted markup for the treeview.



    The current project I'm working on was ripe for saving time using an &lt;asp:treeview&gt; control, but I couldn't justify using a tablular data for navigation in my semantic XHTML page, so I knocked up a nested list workaround in JS/CSS/DOM in the end.



    I really appreciate that you are listening to feedback and are working hard to provide additional interim releases. Can't wait to be able to drop one of these babies into my page and forget about it :o)



    Scott



    (Scott Lowe)

  • Hi Scott,

    Thank you for the link. The tutorial is great. However, i have a question. Can we have multiple root nodes in a sitemap? If yes, how do we implement it? I am looking to use SQLSiteMapProvider. I will appreciate your response.



    Thanks!



  • Hi Goz,



    Yep -- we are planning to release a lot more data tutorials over the next few weeks. So much more information on this should be coming soon.



    Hope this helps,



    Scott

  • Hi Damon,



    I think the goal is to get the new CSS adapters out in the next month or so. They shouldn't require any coding changes -- you just update your .browser file with them and then they will be the default rendering when used on a site.



    Hope this helps,



    Scott

  • Hi Scott,

    Thank you for your tip. That did help me. i had another question. I have a single SiteMapDataSource. How can i bind this to two different controls, say menu to display parents and treeview to display children?

    Is this possible?



    Thanks!

    Saumin

  • Damon/Scott -- goal is to get the CSS Adapter stuff live in early April -- we have protoypes together and the contet is coming together well :) I think everyone is going to love it -- samples of Menu, TreeView, DataList, GridView, DetailsView...

  • Was playing around with basic site map a bit over the weekend. Is there a way without a custom provider to have a subcategory with no url show up in the path. so if you had a code books page and bestsellers books page, etc and you wanted



    Home &gt; Books &gt; Bestsellers



    in the sitemap for the bestsellers page, but there was really no default &quot;Books&quot; page. Is this doable? I couldn't get it to work.

  • Hi Saumin,



    Yep - you should be able to point to controls at the same SiteMapDataSource just fine. You can also add a second SiteMapDataSource control to the page if you want to as well.



    Hope this helps,



    Scott

  • I like the idea about being able to use the treeview and have it rendered as an unordered list.



    This would be key for standards-based development and opens the door to infinite possibilities. Keep up the good work guys!



    Thanks.

Comments have been disabled for this content.