Html.EditorFor loading custom templates

In my program that I put

<%: Html.EditorFor(m => m.EducationData , "~/Views/HTML/Shared/EditorTemplates/Foo/CustomTemplate.ascx")%> 

but it doesn’t load editor templates from the path I specified. I saw in some examples a link where they set custom paths for templates. Can anyone suggest something? or does MVC2 support custom paths for editor templates? or Is there a way to configure web.config or some configurations, so I could change the default templates location ???

+7
source share
1 answer

I think you have too many folders. There is a special convention that you must adhere to when using EditorTemplates and DisplayTemplates. Try placing your templates in this folder and it should work:

 "~/Views/Shared/EditorTemplates/CustomTemplate.ascx" 

Update:

Not all of your editortemplates must be in a shared folder. You can also install controller-specific templates in folders depending on the controller:

 "~/Views/Home/EditorTemplates/CustomTemplate.ascx" 
+7
source

All Articles