Dynamic Views based on view models

Posted by Joe on Stack Overflow See other posts from Stack Overflow or by Joe
Published on 2010-03-29T16:04:11Z Indexed on 2010/03/29 16:13 UTC
Read the original article Hit count: 138

Filed under:
|
|

I have an asp.net mvc 2 app. I need to display the same page to each user. But each user has different rights to the data. IE some can see but not edit some data, some cannot edit nor see the data. Ideally data that cannot be seen nor edited is whitespace on the view. For security reasons I want my viewmodels to be sparse as possible. By that I mean if a field cannot be seen nor edited , that field should not be on the viewmodel. Obviously I can write view for each view model but that seems wasteful. So here is my idea/wishlist

Can I decorate the viewmodel with attributes and hook into a pre render event of the html helpers and tell it to do   instead???

Can I have the html helpers output   for entries not found on the viewmodel??

or

can I easily convert a view built into code then programaticlly build the markup and then put into the render engine to be processed and viewd as html on client side??

© Stack Overflow or respective owner

Related posts about viewengine

Related posts about asp.net-mvc