asp.net-mvchtml-helpereditorfor

Override EditorForModel Template


You can provide alternate templates for individual types, but is it possible to override the template that wraps the label, field and validation up.

Change:

<div class="editor-label"><label for="Content">Content</label></div>
<div class="editor-field"><input class="text-box single-line" id="Content" name="Content" type="text" value="" /> </div>

To:

<div class="field">
<label for="Content">Content</label>
<input class="text-box single-line" id="Content" name="Content" type="text" value="" /> </div>

Rich


Solution

  • You can write an Object.ascx template and perform your own logic.