I am working on an inventory system, developing a website using asp.net & c#. I want that my menu gets invisible & visble as per the user role. Means if admin login then he can view all menus but if accountant login then he can view only some menu items only.
Please help,,its urgent
Loading
Mayur DighePosted Feb 3, 2012, 11:02 AM
you can do this by simply calling some functions (e.g. LoginAdmin(), LoginAccnt() etc.), in which you can place a code to Enable or Disable the Menu Items........
For expected Result that you want, you need to call these functions at time of LOGIN with proper 'UserName' that you want...
Example:
Login Page:-
User Name: Admin
Password : Admin
Click 'Login' Button
@ 'OnClick' event of 'Login' Button:-
if(username=="Admin")
{ LoginAdmin(); }
else if(username=="Accountant")
{ LoginAccnt(); }
Functions:
LoginAdmin()
{
mnuBudget.Enable=true;
mnuPayment.Enable=true;
}
LoginAccnt()
{
mnuBudget.Enable=false;
mnuPayment.Enable=false;
}