Denny.NET

I can haz ASP.NET goodness?

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

Disclaimer

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

© Copyright 2008

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.

[code:c#]
protected void MasterMenu_MenuItemDataBound( object sender, MenuEventArgs e ) {
     if( e.Item.Text == "Account" ) {
         MasterMenu.Items.Remove( e.Item );
     }
}
[/code]
 

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

Currently rated 3.8 by 4 people

  • Currently 3.75/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

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

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

Tuesday, July 08, 2008 2:46 PM