Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Menu items and Roles

Reply
Thread Tools

Menu items and Roles

 
 
Chuck P
Guest
Posts: n/a
 
      03-07-2007
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?
 
Reply With Quote
 
 
 
 
Sundar Narasiman
Guest
Posts: n/a
 
      03-08-2007
If you use sitemap as the data-source for MenuControls, you can trim the menu
items based on the user role. Please refer the following link

http://msdn2.microsoft.com/en-us/lib...29(vs.80).aspx

If you have custom data-source (other than site-map), you need to write your
custom logic to do this



--
Thanks & Regards,
Sundar Narasiman


"Chuck P" wrote:

> 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?

 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      03-08-2007
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...-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/subscripti...ult.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/subscripti...t/default.aspx.

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



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




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing Menu Items and Child Menu Items Larry Bud ASP .Net 13 01-07-2008 02:12 PM
All items show in menu even when roles are specified Chicagoboy27 ASP .Net 1 12-12-2006 11:29 PM
Hide Menu Items Based On Roles beaudetious ASP .Net Web Controls 3 01-09-2006 01:48 AM
Application level roles + Item level roles... how to do it? Jéjé ASP .Net Security 0 09-26-2005 11:06 PM
How to create dynamic menu with user roles (Treeview menu) naijacoder naijacoder ASP .Net Web Controls 0 09-27-2004 09:33 AM



Advertisments