I am using VS2005 C# ASP.NET.
I have a webform which contains a list of users in a ListBox tool.
I would like to check if the selected user in the ListBox is in a specific role, how can I do it?
Below is my current code:
if (UsersListBox.SelectedItem != null)
{
rolesArray = Roles.GetRolesForUser(UsersListBox.SelectedItem.Value);
//check if the selected user is in role "Administrator"
}
I have tried using this.User.IsInRole("Administrators"). However it will only retrieve the role of the active user instead of the selected user in the ListBox.
1 Answer