1

I am using MVC 5 in my Model I need to localize DataAnnotation, using the following code

[Required]
[Display(Name = Resources.Account_Login_UserName)]
public string UserName { get; set; }

I receive this error:

An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type

Any idea how to fix it?

Soner Gönül
  • 94,086
  • 102
  • 195
  • 339
GibboK
  • 68,054
  • 134
  • 405
  • 638

1 Answers1

3
[Display(Name = "Account_Login_UserName", ResourceType = typeof(Resources))]
Soner Gönül
  • 94,086
  • 102
  • 195
  • 339
meziantou
  • 19,250
  • 7
  • 58
  • 77
  • thanks for your answer, I have a similar related question http://stackoverflow.com/questions/20699594/how-localize-errormessage-in-dataannotation could you help? thanks – GibboK Dec 20 '13 at 08:50