EditorTemplate Naming Convention for Collection model classes

混江龙づ霸主 提交于 2019-12-02 01:29:18

You could use the [UIHint] attribute:

public class MyModel
{
    [UIHint("TemplateForTheList")]
    public List<MyClass> MyProperty { get; set; }
}

or specify the template name as second parameter to the DisplayFor helper:

@model MyModel
@Html.DisplayFor(m => m.MyProperty, "TemplateForTheList")

and then have a TemplateForTheList.cshtml template:

@model List<MyClass>
...

In this case the templating engine will not render the template for each element of the collection property. It will simply pass the collection itself to the template.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!