Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Html.EditorFor not loading custom template paths

In my program I have put,

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

but it doesn't load the editor templates from the path I've given. I've seen in some of the examples,link where they have given custom paths for the templates. Can anyone suggest something? or does MVC2 supports custom paths for editor templates? or Is there a way to customize the web.config or some configurations,so I could change the default template locations???

like image 322
SDK Avatar asked Jul 30 '12 10:07

SDK


1 Answers

I think you have too many folders. There is a specific convention you should follow when using EditorTemplates and DisplayTemplates. Try putting your templates in this folder and it should work:

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

Update:

Not all of your editortemplates need to go into the Shared folder. You can put controller-specific templates into controller-specific folders too:

"~/Views/Home/EditorTemplates/CustomTemplate.ascx"
like image 156
danludwig Avatar answered Nov 06 '22 16:11

danludwig