GibboK
GibboK

Reputation: 73928

How to localize DataAnnotation in MVC?

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?

Upvotes: 1

Views: 284

Answers (1)

meziantou
meziantou

Reputation: 21337

[Display(Name = "Account_Login_UserName", ResourceType = typeof(Resources))]

Upvotes: 3

Related Questions