我在使用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屬性可能是正確的選擇。謝謝 –