This project is read-only.

Hiding Widgets?

Jun 24, 2010 at 10:37 AM


I have 3 different roles (Administrators, Editors and Users) but I only want the pages widget to appear for 2 of them (Administrators and Editors). Is ir possible to hide this widget from Users and people who are not logged in?



Jun 25, 2010 at 9:32 AM

You can use the System.Security.Principal namespace's objects and methods to detect what type of role the current user is in and act accordingly, here's an example


//Code which displays the widget


 The only role you're going to be able to programmatically look up the name of is the AdministratorRole, I believe, which you can do using this:

if (Page.User.IsInRole(BlogSettings.Instance.AdministratorRole)){

//Code which executes only upon requests from users authenticated as admins...