Html.LabelFor Specified Text

后端 未结 7 1587
渐次进展
渐次进展 2020-12-24 04:28

Anyone got any idea on how to specify text when using Html.LabelFor(c=>c.MyField). It\'s just MyField might not be an appropriate name to displ

7条回答
  •  清歌不尽
    2020-12-24 05:03

    There are two ways
    1"direct annotations"
    2"Annotatinos with a resource"
    Direct annotations

    [Display(Name = "My Field")]
    public string MyField { get; set; }
    

    Annotatinos with a resource

    [Display(Name = "My_Field",ResourceType = typeof(Resource))]
    public string MyField { get; set; }
    

    Second way will require to add a value in resource file probably named as Resource.resx.
    Use which suits your purpose.

提交回复
热议问题