开发者

ASP.NET MVC - Form Value display by role [duplicate]

开发者 https://www.devze.com 2022-12-08 02:27 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: ASP.NET MVC - Form Value display by role
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

ASP.NET MVC - Form Value display by role

I'm looking for an ideal way for my input forms to either show as a textbox (editable), label (readonly), or hidden (no access) based on the roles. I know I could have a different view for each type of role but I was hoping that there's some new goodness out there that would p开发者_如何学Pythonrevent me from having to do 80 views.


Add a DisplayMode property to your model and customise the View accordingly. That way if you decide to change the rules over what role sees what version of the View you only have to update the Controller, not the View.


I'd write a simple WebControl that you can pass the data to and the, as @ctford suggests, display mode.

Depending on the display mode passed to the WebControl you could then either render a TextBox, Label or Hidden field.

Nice, neat and reusable.

0

精彩评论

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

关注公众号