This is a migrated thread and some comments may be shown as answers.

RadMenu with roles

2 Answers 83 Views
Navigation
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Terry
Top achievements
Rank 1
Terry asked on 21 Jun 2012, 07:07 PM
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 Answers, 1 is accepted

Sort by
0
Lancelot
Top achievements
Rank 1
answered on 25 Jun 2012, 05:59 PM
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
0
Terry
Top achievements
Rank 1
answered on 25 Jun 2012, 07:33 PM

Thank you Lancelot.  This is how I will proceed.


Terry
Tags
Navigation
Asked by
Terry
Top achievements
Rank 1
Answers by
Lancelot
Top achievements
Rank 1
Terry
Top achievements
Rank 1
Share this question
or