Search code examples
asp.netsitemapaspmenu-control

How to add a class to locked pages in asp:Menu


I am binding a web.sitemap to an asp:Menu, and want to assign classes to the menu items that require a login to access.

I know that in the siteMap section of the web.config file, if I set securityTrimmingEnabled="true" that it will only show items available to that user (roles/logged out/logged in). This is fine with me, but the users want to see these links.

So I am trying to make an indicator that these pages are locked, preferably adding a class to those links.

Thanks in advance!


Solution

  • You may use a custom ITemplate for the DynamicItemTemplate property of the Menu. As alternative (I guess with less code but I never tried) you may attach to MenuItemDataBound event.