为什么我不能用属性设置 ShowForEdit
模型元数据?
似乎提供的唯一改变它的属性是 [ScaffoldColumn]
,它设置了 ShowForEdit
和 ShowForDisplay
,这不是什么我想要做。我希望能够在我的模型上分别注释这两者。
最佳答案
因为它不支持开箱即用。 AFAIK 原因是因为支持此功能的 dataannotations 属性位于 .net 4.0 中,为了使 MVC 3.5 和 4.0 兼容,必须排除它们。
解决此问题的最简单方法是必须实现您自己的 Edit/Show 属性,如本问题/答案中所示:
Showing Different fields in EditorForModel vs. DisplayForModel modes in MVC2
关于asp.net-mvc - ASP.NET MVC : Why can't I set ShowForEdit model metadata with an attribute?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3013051/