我在使用Scaffolding Nuget创建CRUD视图的MVC 4项目中使用了Data Annotations。我正在使用层级数据库模型而不是EF。MVC 4数据注释
所以我的课的样子如下:
[MetadataType(typeof(CustomerMetaData))]
public partial class UserProfile: IBrObject
{
public UserProfile(string aspUserName): this()
{
this.AspUserName = aspUserName;
}
public string AspUserName { get; set; }
public DateTime MetaDateFirstSaved { get; set; }
}
public class CustomerMetaData
{
[ReadOnly(true)]
[ScaffoldColumn(false)]
[DisplayName("ASP UserName")]
public object AspUserName { get; set; }
[DisplayName("Date First Saved")]
[DataType(DataType.Date)]
public object MetaDateFirstSaved { get; set; }
}
当我试图创建脚手架的NuGet意见仍然显示AspUserName列不隐藏或只有不读。 我如何隐藏或只读?
可能重复[是否只读(真)与Html.EditorForModel合作?](http://stackoverflow.com/questions/3510081/does -readonlytrue-work-with-html-editorformodel) –
“Mystere Man”uihint属性可能是正确的选择。谢谢 –