Menu items and Roles

Discussion in 'ASP .Net Web Controls' started by Chuck P, Mar 7, 2007.

  1. Chuck P

    Chuck P Guest

    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?
     
    Chuck P, Mar 7, 2007
    #1
    1. Advertising

  2. 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/library/ms178429(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?
     
    Sundar Narasiman, Mar 8, 2007
    #2
    1. Advertising

  3. 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.
     
    Steven Cheng[MSFT], Mar 8, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chicagoboy27
    Replies:
    1
    Views:
    343
    Chicagoboy27
    Dec 12, 2006
  2. Larry Bud
    Replies:
    13
    Views:
    7,819
    Larry Bud
    Jan 7, 2008
  3. Microsoft Newsserver

    ASP.NET Menu Items - Dynamic Items Disapearing

    Microsoft Newsserver, Feb 22, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    415
    bruce barker
    Feb 22, 2008
  4. naijacoder naijacoder

    How to create dynamic menu with user roles (Treeview menu)

    naijacoder naijacoder, Sep 27, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    377
    naijacoder naijacoder
    Sep 27, 2004
  5. beaudetious

    Hide Menu Items Based On Roles

    beaudetious, Jan 8, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    224
    sloan
    Jan 9, 2006
Loading...

Share This Page