Reputation: 17373
I've got a web form with lots fields and buttons. These fields and buttons should be enabled and disabled based on users Role i.e. 'employee', 'team leader', 'manager' etc.
Is there a way to tag each fields such as emp for employee, tm for teamleader so that I can enable or disable them with 1 or 2 lines of code?
Otherwise I will have to write lots of if else statement for each controls.
thank you
Upvotes: 1
Views: 158
Reputation: 887797
You can create WebControl[]
arrays in the code-behind containing the controls visible to each role:
WebControl[] managerControls = { someControl, otherButton, ... };
Upvotes: 1