Official "How to" for MVC Editor/Display Templates?
Asked Answered
B

3

12

I have been using MVC Editor & Display Templates for a while, but have come to realize that there seems to be very little official documentation on MVC Editor/Display Templates (Html.EditorFor() and Html.DisplayFor()). I found the basic MSDN documentation just showing the technical details (which on their own, are not very helpful), but I'm looking more for an official how-to, sort of like this example.

Are Editor/Display Templates more of an afterthought, and not really widely enough used to justify more in-depth official documentation?

Or, am I blind, and what I'm looking for exists, I just haven't found it yet?

Bailable answered 28/9, 2012 at 17:26 Comment(4)
They are actually very well used by the default scaffolded view templates.Thrum
It's now 2017 and I have yet to find any docs or article(s) on how to edit a phone number within a template. e.g. "(###) ###-####" I'm still trying to figure out whether or not it's even possible! :(Marriageable
2021; still almost impossible to find good explanations on custom real life complex partials. I however; keep finding 12-15 years old explanations using old mvc framework version 2.Gametocyte
Or it reverts to CORE examples not using RAZORGametocyte
R
3

Official documentation? Don't know any off hand, but I know there are a ton of examples. In particular, I like Phil Haack's discussion on model binding to lists. It includes an example for an editor template in a pretty complicated example. There's source code there, too.

Since he's co-authored every MVC Wrox book, I consider him a pretty definitive source:

http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx

Here's another blog post (non-official) in a similar vein:

http://blogs.msdn.com/b/stuartleeks/archive/2010/03/30/collections-and-asp-net-mvc-templated-helpers-displayfor-editorfor.aspx

Rearm answered 28/9, 2012 at 18:20 Comment(0)
U
3

best article that I have found for it is:

http://www.growingwiththeweb.com/2012/12/aspnet-mvc-display-and-editor-templates.html

It explains how to create DisplayFor and EditorFor templates really well.

Unstopped answered 24/8, 2014 at 15:48 Comment(2)
Your definition of "really well" is a lot different than mine. That article has some simple tips but doesn't really explain anything in detail.Spermiogenesis
back in 2014 that 2012 article was good enough for us to move on 😊 I guess times change 😁Unstopped
F
1

ASP.NET MVC have a lot of materials on http://www.asp.net/mvc with different examples. EditorTemplates and DisplayTemplates is spetial folders for models (like here Quick Tips About ASP.NET MVC – Editor Templates) and you asking about html helpers, not templates.

Flexure answered 28/9, 2012 at 18:6 Comment(2)
Except when you click go deeper it reverts to COREGametocyte
also; second link is 404Gametocyte

© 2022 - 2024 — McMap. All rights reserved.