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?

Vilx-
  • 104,512
  • 87
  • 279
  • 422
  • http://stackoverflow.com/questions/14425994/mvc-4-custom-template-for-bool-razor Just take care that bool --> Boolean.cshtml – Bishoy Hanna Mar 13 '14 at 06:14
  • The best guide to templates that I know of is Brad Wilson's guide: [Brad Wilson: ASP.NET MVC 2 Templates, Part 1: Introduction](http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-1-introduction.html) While this is for MVC2, this behaviour hasn't changed for MVC3. – Linkgoron Mar 31 '11 at 08:41
  • Also take a look at http://www.dalsoft.co.uk/blog/index.php/2010/04/26/mvc-2-templates/ – DalSoft Oct 21 '12 at 15:00

1 Answers1

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.

Gerard
  • 2,649
  • 1
  • 28
  • 46
  • 1
    Nice! Also, here's the [source code](http://aspnetwebstack.codeplex.com/SourceControl/latest) for MVC4, found from your link. This will be useful! :) – Vilx- Sep 03 '13 at 10:17
  • 2
    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 link – Stuart Dobson Jun 03 '14 at 07:40