Dud*_*lou 7 .net c# asp.net-mvc
我们可以使用System.ComponentModel.DataAnnotations.DisplayAttribute为属性设置标签,我想将它用于类,但不允许在类上使用它.
using System.ComponentModel.DataAnnotations;
[Display(Name = "A person")]
public class Person
{
[Display(Name = "A name")]
public string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
有人知道解决方法吗?
编辑:我想在强类型视图上使用它.当我创建一个新的强类型视图时,类名称是用HTML硬编码的,如下所示:
@model Models.Person
<fieldset>
<legend>Person</legend>
<div class="display-label">
@Html.LabelFor(model => model.Name)
</div>
</fieldset>
Run Code Online (Sandbox Code Playgroud)
我想做一些类似于Name房产的事情.