Sergii
Sergii

Reputation: 44

How can I use default MVC editor if i have defined editor template for particular type?

How can I use default MVC editor if i have defined editor template for particular type?

For instance I have editor for string type("string.cshtml") in "Editors" folder. When I use

@Html.EditorFor(x => x.MyStringField)

it uses my template("string.cshtml"). But I have area in my application and I want use there default MVC editor template for string type. Is it possible?

Upvotes: 0

Views: 117

Answers (1)

Kirill Bestemyanov
Kirill Bestemyanov

Reputation: 11964

You should place your editor template in folder Views\Shared\EditorTemplates in your area or in your root folder.

If you want, you can set editor template for current property:

@Html.EditorFor(x => x.MyStringField, "editorTemplateName");

In this case you should name editor template custom name (not string).

Upvotes: 1

Related Questions