RadMenu with roles

3 posts, 0 answers
  1. Terry
    Terry avatar
    157 posts
    Member since:
    Jul 2009

    Posted 21 Jun 2012 Link to this post

    Hi:

    I am upgrading a Telerik Silverlight app to use roles for the menu -- i.e. only allow people in certain ASP.NET membership roles to see or execute certain menu items.  In non-SL code, I would use a sitemap, but that does not seem to be an option here.  How do I enforce roles with a RadMenu?
  2. Lancelot
    Lancelot avatar
    251 posts
    Member since:
    Jul 2012

    Posted 25 Jun 2012 Link to this post

    Terry,

    With Silverlight you can collapse certain items in the RadMenu if conditions are not met. For instance:

    if(IsUserAdmin)  // this checks for "true", you could reverse it by using !IsUserAdmin
    {
         this.ImportantRadMenuButton1.Visibiity = Visibility.Visible;
         this.ImportantRadMenuButton2.Visibiity = Visibility.Visible;
    }
    else if(IsNormalUser)
    {
         this.ImportantRadMenuButton1.Visibiity = Visibility.Collapsed;
         this.ImportantRadMenuButton2.Visibiity = Visibility.Collapsed;
    }


    You would apply this method example in a page loaded event or a user role changed event, where ImportantRadMenuButton is a menu item that you only want Admin roles to see. IsUserAdmin in this example is a bool that is associate with a role, but depending on the way your app has it's roles stored you just check for a true/false condition and then collapse/show menu items accordingly.

    This link will bring you to the documentation for the IsEnabled property of the control items, the main difference between this and collpased is the user will be able to see the menu items even though they can't click them.

    Good Luck,
    Lancelot
  3. DevCraft banner
  4. Terry
    Terry avatar
    157 posts
    Member since:
    Jul 2009

    Posted 25 Jun 2012 Link to this post

    Thank you Lancelot.  This is how I will proceed.


    Terry
Back to Top