Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 10, 2012 06:27 PM by Madhu1234
May 10, 2012 02:48 PM|LINK
I am new to asp.net I have to do a task which is to disable some controls for users if they dont have permission.in a page, if the user is basic user, then that user can view the data but the update and delete button should be disabled.but if the user has
got update privilege then the update button should be enabled. and if the user has both update and delete privilege then both update and delete button should be enabled.
how to do this task?
May 10, 2012 02:56 PM|LINK
May 10, 2012 06:27 PM|LINK
Step 1:First assign roles(to your users like admin,member..) in Global.asax like below.
protected void Application_AuthenticateRequest(object sender, EventArgs e)
string arRoles = new string;
arRoles = "r1"; arRoles = "r4";
arRoles = "r2"; arRoles = "r4";
arRoles = "r3"; arRoles = "r4";
Context.User = new System.Security.Principal.GenericPrincipal(User.Identity, arRoles);
Step 2:Then based on ur requirement enable/disable the required buttons like below..
protected void Page_Load(object sender, EventArgs e)
btnUpdate.Visible = User.IsInRole("r2");
Hope this helps you ..