Let's say we have a pretty complex MVC application with many fields and business logic to be embedded in a view (eventually). For instance, let's say we have tens of fields to display (in a single view), which many of them can be enabled or disabled based on various conditions. Or even some fields may be hidden or displayed with a different type control (just text instead of a HTML control). All these rules may be based on data (values in some fields) and/or roles of current user.
My question would be how can somebody implement all these in MVC spirit?
Yes, we can have in model for all fields some extra properties which will tell us if that specific field needs to be enabled or disabled or hidden completly, or displayed as just text instead of different control, and then in view check these properties when displayed the field. (just that this require some consistent work when you have a lot of fields)
Something like (pseudocode) this for each field
<%
if(model.Field1Visible) {
if(model.Field1Text) { %>
<%: Html.LabelFor(m => model.Field1) %>
<% } else { %>
<%: Html.TextBoxFor(model => model.Field1, new {disabled = model.Field1Disabled} )%>
<% }
} %>
Creating separate views based on some conditions (let's say per
View Complete Post