如何在类常量中使用DisplayNameFor?

时间:2019-01-14 13:02:26

标签: asp.net-core html-helper

我有这个课程,想显示用户友好的名称。怎么做?

public static class NavigationRoles
{ 
    [Display(Name = "Structure d'offre de service")]
    public const string STRUCTURES = "STRUCTURES";
}

在我的视图中尝试使用此@Html.DisplayNameFor(m => NavigationRoles.STRUCTURES)会返回一个InvalidOperationException 模板只能与字段访问,属性访问,一维数组索引或单参数自定义一起使用索引器表达式

0 个答案:

没有答案