Question

I'm trying to just ever so slightly tweak the default EditorTemplate for a SelectList. Is there somewhere where I can find the source for all the default EditorTemplates (i.e so I have a base reference to work off of).

I've had a peek on the asp.net mvc source page and cannot find the templates listed in their source code (although I am most likely missing it).

Was it helpful?

Solution

The default EditorTemplate for a SelectList is actually just this method: System.Web.Mvc.Html.SelectExtensions.SelectInternal()

So it is not implemented as a .cshtml template at all. Instead it builds up the markup in C# using a TagBuilder. You could take this implementation as a starting point for your own C# method, or else port it into the equivalent razor syntax.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top