在我的节目里,我已经把,
<%: Html.EditorFor(m => m.EducationData
, "~/Views/HTML/Shared/EditorTemplates/Foo/CustomTemplate.ascx")%>
但它没有从我给出的路径加载编辑器模板。我在一些示例link中看到过,他们为模板提供了自定义路径。谁能提出建议?或者MVC2是否支持编辑器模板的自定义路径?或者有没有办法自定义web.config或某些配置,所以我可以更改默认模板位置???
答案 0 :(得分:7)
我认为你的文件夹太多了。使用EditorTemplates和DisplayTemplates时应遵循一个特定的约定。尝试将模板放在此文件夹中,它应该可以工作:
"~/Views/Shared/EditorTemplates/CustomTemplate.ascx"
<强>更新强>
并非所有的editortemplate都需要进入Shared文件夹。您也可以将特定于控制器的模板放入控制器特定的文件夹中:
"~/Views/Home/EditorTemplates/CustomTemplate.ascx"