How to create custom editor/display templates in ASP.NET MVC 3?
Asked Answered
F

1

62

I would like to make custom editor templates for different data types in ASP.NET MVC (to use with Html.EditorFor()), including rewriting the existing templates. The ultimate goal is to create a mini-framework where each editor supports javascript notifications about being changed, and I can show a message to the user that there are unsaved changes in the page. (Maybe there's something existing already?)

I can find many questions pertaining to problems with such templates, but nowhere can I find a tutorial or manual on creating them. Where do they go? Is there any special syntax? How does a template get selected? What information is available in the template and how do I access it? Etc.

So - where can I find out all about these templates?

Freemason answered 31/3, 2011 at 8:36 Comment(3)
The best guide to templates that I know of is Brad Wilson's guide: Brad Wilson: ASP.NET MVC 2 Templates, Part 1: Introduction While this is for MVC2, this behaviour hasn't changed for MVC3.Abstruse
Also take a look at dalsoft.co.uk/blog/index.php/2010/04/26/mvc-2-templatesPareira
#14426494 Just take care that bool --> Boolean.cshtmlPsalm
B
3

Check and download ASP.NET MVC 3 Futures on http://aspnet.codeplex.com/releases/view/58781 and see how the default source code looks. Note: this works for MVC 4 as well.

Barometer answered 3/9, 2013 at 8:41 Comment(2)
Nice! Also, here's the source code for MVC4, found from your link. This will be useful! :)Freemason
Especially given that a lot of code moves from Codeplex to GitHub, it would be much better if your answer actually contained an answer instead of just a linkCowardly

© 2022 - 2024 — McMap. All rights reserved.