Menu items and Roles

C

Chuck P

I have menu items in a Master Page defined like this.

<asp:Menu ID="Menu1" runat="server" SkinID="Horizontal">
<Items>
<asp:MenuItem Text="Surveys To Do" Value="Surveys To Do"
NavigateUrl="~/Default.aspx"></asp:MenuItem>


Can I disable a menu item based on a role?
 
S

Steven Cheng[MSFT]

Hello Chuck,

As for the disable certain MenuItem in ASP.NET menu control, do you mean
make the menuitem hidden from those unauthorized users or still display
them but not provide hyperlink?

Based on my understanding, ASP.NET 2.0 Menu control and the SiteMap
provider provide a security trimming feature which can help control the
visiblility of navigation items(from web.sitemap file) in Menu or TreeView
control. The display rule is depend on two settings:

1. The <authorization> setting will always be checked first, if a user
doesn't have access to a sitemapnode according to this setting, the
corresponding item(in menu or treeview) will be hidden, otherwise, the item
will be displayed.

2. In each <siteMapNode> it has a "roles" attribute that can help you add
additional customize (based on the former setting in #1). If a user can not
access a sitemapnode(its url) according to <authorization> setting, you can
add it into that certain <siteMapNode>'s "roles" attribute so that the user
can still see the node in Menu or TreeView control(though he still can not
navigate to the actual url/page).

Here are the MSDN reference and a good blog article that demonstrate this
feature:


#ASP.NET Site-Map Security Trimming
http://msdn2.microsoft.com/en-us/library/ms178428.aspx

#Recipe: Implementing Role-Based Security with ASP.NET 2.0 using Windows
Authentication and SQL Server
http://weblogs.asp.net/scottgu/pages/Recipe_3A00_-Implementing-Role_2D00_Bas
ed-Security-with-ASP.NET-2.0-using-Windows-Authentication-and-SQL-Server.asp
x

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top