DennyDotNet

Awesome ASP.NET C# and other cool coding stuff

About the author

Denny Ferrassoli
Developer at Casting Networks. MCP / .NET
E-mail me Send mail
Add to Technorati Favorites

Recent posts

Recent comments

Authors

Categories

None


Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

Removing an Item from a SiteMap Menu at Runtime

Yesterday I was implementing a new SiteMap menu and had to apply a boat load of business rules to the menu. At first I thought I could hide certain menu items by using Roles. However I quickly realized that not only do I have to apply these business rules based on roles but certain configuration settings as well, so roles would not work. Since the SiteMap file is essentially a static XML file I really didn't want to do any XML parsing. I felt it would be far too expensive to edit the XML in memory. So finally this morning I found what I needed. A simple way to remove items from a sitemap.


protected void MasterMenu_MenuItemDataBound( object sender, MenuEventArgs e ) {
     if( e.Item.Text == "Account" ) {
         MasterMenu.Items.Remove( e.Item );
     }
}
 

The only issue I have with this method is that I have to run through my business logic for every item in the menu.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Posted by Denny on Thursday, October 18, 2007 3:47 AM
Permalink | Comments (0) | Post RSSRSS comment feed

Comments

Comments are closed