开发者

Should I add another view to display the same page with one less field?

I am just making the switch from WebForms to MVC and would like to ask what are the best ways of hiding particular fields in the view. Assuming we have a model named WishList that has a list of gifts kids want for Christmas and the child's name. We want the elves to view the list of gifts, but only Santa Claus can view the child's name开发者_如何学运维. Would it be best to have two views for the WishList (one for Santa and one for the elves) or is there another way to handle this? My concern is that the number of views can start piling as high as the snow does in the North Pole by the time I enforce all of the visibility settings required in my application.


You could try to hide the field using a client-side scripting language like jQuery, or you could actually put a bit of logic in the view itself that determines whether or not certain parts of the view are displayed.

Something like:

<% if (user.HasAccess) {%>
<input id="myInput" />
<%}%>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜