是否有一个属性可以与 ASP.NET MVC 3 一起使用来防止模型字段自动显示在我的 View 中?我的意思是我有如下类:
public class EntityBase
{
public int ID { get; set; }
//more fields...
}
public class TestEntity : EntityBase
{
public string TestEntityName { get; set; }
//more fields...
}
我了解 System.ComponentModel
和 System.ComponentModel.DataAnnotations
中用于强制验证的所有属性 - Required
、 StringLength
等 - 但是当我从 Visual Studio 创建 View 时,是否可以使用它来阻止某些字段显示在 View 中?我项目的所有模型类都继承自 EntityBase
,但我不希望 EntityBase
的任何字段在 View 上可见。我使用 Razor 作为我的 ViewEngine,以防万一。
TIA,
类吉
最佳答案
使用脚手架列:
[ScaffoldColumn(false)]
关于c# - 是否有一个属性可以与 ASP.NET MVC 3 一起使用来防止模型字段自动包含在我的 View 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6782888/