简体   繁体   中英

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???

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM