开发者

ASP.NET Server Controls Tag for Role Based Authorization

开发者 https://www.devze.com 2023-03-09 18:10 出处:网络
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.

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


You can create WebControl[] arrays in the code-behind containing the controls visible to each role:

WebControl[] managerControls = { someControl, otherButton, ... };
0

精彩评论

暂无评论...
验证码 换一张
取 消