editortemplates

ASP.NET MVC 3 - Partial vs Display Template vs Editor Template

浪子不回头ぞ 提交于 2019-11-26 11:57:50
So, the title should speak for itself. To create re-usable components in ASP.NET MVC, we have 3 options (could be others i haven't mentioned): Partial View: @Html.Partial(Model.Foo, "SomePartial") Custom Editor Template: @Html.EditorFor(model => model.Foo) Custom Display Template: @Html.DisplayFor(model => model.Foo) In terms of the actual View/HTML, all three implementations are identical: @model WebApplications.Models.FooObject <!-- Bunch of HTML --> So, my question is - when/how do you decide which one of the three to use? What i'm really looking for is a list of questions to ask yourself

When do I use View Models, Partials, Templates and handle child bindings with MVC 3

你离开我真会死。 提交于 2019-11-26 11:07:37
问题 new to mvc3, i have a few questions, would appreciate if someone could answer/provide links: When should I use View Models? Is it not recommended to use the domain? I find that my view models are copies of my domain objects, and don\'t see the value... When should I use Partials? Is it only if the partial view will be reused? When should I use Display Templates and Editor Templates? Can I use these without a view model? How do I create an edit screen where the parent and list of child objects