I am creating LOB business application using ASP.NET MVC. In my views I find this pattern repeated a lot:
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
It must be possible to write a helper to reduce it down to something like this:
@EditorForField(model => model.Name)
This will make the views simpler, and make it easier to change the form layout to table based layout (if required)
Any ideas how to make such a helper method?
Thanks!
I was able to make this work by this code:
In your View: