I have for example a class:
public class Book
{
public int BookId { get; set; }
public string BookName { get; set; }
public string Description { get; set; }
}
and an editor template:
@model MySimpleEditorTemplate.Models.Book
@Html.DisplayFor(p => p.BookId) @Html.EditorFor(p => p.BookId)
@Html.DisplayFor(p => p.BookName) @Html.EditorFor(p => p.BookName)
@Html.DisplayFor(p => p.Description) @Html.EditorFor(p => p.Description)
I can use the editor template like this:
@Html.EditorFor(model => model.Book)
However what if I want to have two editor templates or two display templates and use one or other for the same class? Is this possible?
Yes
http://msdn.microsoft.com/en-us/library/ff406506.aspx
“If a template whose name matches the templateName parameter is found in the controller’s EditorTemplates folder, that template is used to render the expression. If a template is not found in the controller’s EditorTemplates folder, the Views\Shared\EditorTemplates folder is searched for a template that matches the name of the templateName parameter. If no template is found, the default template is used.”