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
  • 97,193
  • 102
  • 206
  • 364
GibboK
  • 71,848
  • 143
  • 435
  • 658

1 Answers1

3
[Display(Name = "Account_Login_UserName", ResourceType = typeof(Resources))]
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
meziantou
  • 20,589
  • 7
  • 64
  • 83
  • 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