I'm trying to control the menu options depending user roles and permission, after the user login. I saved the user in session and then I get the roles and permissions from data base, then I want to show the main page which is a Master with the menu options how can I do it without using javascript, I'm using c# asp.net.
Asked
Active
Viewed 1,679 times
3 Answers
1
if(Roles.IsUserInRole(roleName))
{
// show controls accordingly
}
else
{
// hide controls accordingly
}

JG in SD
- 5,427
- 3
- 34
- 46
0
You could handle this with server tags on the .aspx side.
<% if (User.IsRole("Administrator")) { %>
<div>Admin Stuff</div>
<% } %>
or you could handle it all server side and wrap the content in PlaceHolders and show/hide them accordingly
<asp:PlaceHolder id="AdminPlaceHolder" runat="server">
<div>Admin Stuff</div>
</asp:PlaceHolder>
AdminPlaceHolder.Visible = User.IsRole("Administrator");

hunter
- 62,308
- 19
- 113
- 113
-
I'm going on the fact that I have no idea how OP is managing the user session – hunter Jan 18 '13 at 18:27