MVC 4 Data Annotations “Display” Attribute

后端 未结 4 1275
夕颜
夕颜 2021-02-01 01:19

I am starting out with MVC 4 (Razor view engine). (I believe this may apply to MVC 3 and earlier as well.) I am wondering if there is any benefit to using the DisplayAttribute d

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-01 01:58

    Also internationalization.

    I fooled around with this some a while back. Did this in my model:

    [Display(Name = "XXX", ResourceType = typeof(Labels))]
    

    I had a separate class library for all the resources, so I had Labels.resx, Labels.culture.resx, etc.

    In there I had key = XXX, value = "meaningful string in that culture."

提交回复
热议问题