Search code examples
asp.net-mvc-3razort4scaffolding

Is it possible to override MVC View Scaffolding on a property basis?


Is it possible that based on attributes on a property, instead of

<div class="editor-label">
    @Html.LabelFor(model => model.PropertyName)
</div>
<div class="editor-field">
    @Html.EditorFor(model => model.PropertyName)
    @Html.ValidationMessageFor(model => model.PropertyName)
</div>

the following gets scaffolded

   <div class="editor-label">
        @Html.LabelFor(model => model.PropertyName)
    </div>
    <div class="editor-field-tall">
        @Html.TextAreaFor(model => model.PropertyName, new { @rows = 5, @cols = 40 })
        @Html.ValidationMessageFor(model => model.PropertyName)
    </div>

without rewriting, replacing, or copying into a new TT and then extending the mvc scaffolding templates?


Solution

  • without rewriting, replacing, or copying into a new TT and then extending the mvc scaffolding templates?

    No.

    If you want to write your own mvc scaffolding templates, I would read this post which will cover how you can override the T4 templates..