On an ASP.NET-MVC2 project, I have built some user controls that resides in Views\Shared\EditorTemplates and DisplayTemplates folders.
I am trying to pull this templates into a class library, in order to make them reusable, how do I do that!
I don’t know if this might help but a little more details; some of the templates are named after types like (string, Int32, etc) and some are named like RemoteCombo, and specified with a template hint in UIHint.
Unfortunately you can’t just create a library and put ascx files there. You will have to create a ‘code-only’ version of your templates that renders appropriate html.
Microsoft had to do just that in order to deliver default templates inside System.Web.Mvc.dll
More information about templates can be found on this blog – it’s a nice series of posts about templating in MVC. (take a look at ‘Built-In Display Templates’ section)
This is a default Editor Template for Decimals (from System.Web.Mvc.dll)
All default templates can be seen in Reflector in
System.Web.Mvc.Htmlnamespace.