Gho*_*ngi 10 asp.net-mvc displayattribute
结果[DisplayName("foo")]和[Display(Name="foo")]为@Html.LabelFor(x => x.MyProperty)相同.两者都生成<label for="MyProperty">foo</label>.DisplayName的优点是什么?
Jak*_*cki 18
Display属性应优先于DisplayName属性.前者来自形式DataAnnotations命名空间,并且暴露了比后者更多的属性,即.ShortName,Prompt,GroupName,Order,Description,由...使用DataAnnotationsMetadataProvider.
最重要的是,DisplayName只接受文字,同时Display接受资源类型和密钥,可用于使用单独的资源文件(resx)提供翻译.
| 归档时间: |
|
| 查看次数: |
2126 次 |
| 最近记录: |