Override EditorForModel Template
Asked Answered
R

1

5

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

Rhadamanthus answered 27/10, 2009 at 10:56 Comment(0)
S
7

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

Soloma answered 28/10, 2009 at 23:53 Comment(3)
Thanks for the response. This just overrides the base type. What I'm looking is a why to override the template that contains the label, field and validation template. If that is possible.Rhadamanthus
It's the Object template that does that. It iterates through each property of an object and renders those three things. Check out Brad Wilson's series on the topic bradwilson.typepad.com/blog/2009/10/…Soloma
Beg your pardon. Found the Brad Wilson blog under my own steam. Initially I had been expecting to find a single item template, rather than an iterator template and as a result didn't understand what I was seeing in your example. Thanks again.Rhadamanthus

© 2022 - 2024 — McMap. All rights reserved.