Html.Editor不加载自定义模板路径

时间:2022-01-11 03:25:04

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

但是它没有从我给出的路径加载编辑器模板。我已经在一些示例中看到了链接,它们为模板提供了自定义路径。谁能提出建议?或者MVC2是否支持编辑器模板的自定义路径?或者有没有办法自定义web.config或一些配置,所以我可以更改默认模板位置???

1 个解决方案

#1


7  

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:

我觉得你的文件夹太多了。使用EditorTemplates和DisplayTemplates时应遵循一个特定的约定。尝试将模板放在此文件夹中,它应该工作:

"~/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:

并非所有editortemplate都需要进入Shared文件夹。您也可以将特定于控制器的模板放入控制器特定的文件夹中:

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

#1


7  

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:

我觉得你的文件夹太多了。使用EditorTemplates和DisplayTemplates时应遵循一个特定的约定。尝试将模板放在此文件夹中,它应该工作:

"~/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:

并非所有editortemplate都需要进入Shared文件夹。您也可以将特定于控制器的模板放入控制器特定的文件夹中:

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