ASP.NET MVC Validation - localisation of the error string
- by gmang
I followed the techique ASP.NET MVC 2: Model Validation from Scott Gu. (http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx).
However I am building a localised web site. How can I localized the error string?
I tried the following by replacing the following:
[RegularExpression(@"\d{4}",ErrorMessage="Must be a 4 digit year")]
public Nullable YearOfWork { get; set; }
With the following:
[RegularExpression(@"\d{4}",ErrorMessage=Resources.SharedStrings.search_error1)]
public Nullable YearOfWork { get; set; }
but I get a complilation error:
An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type
Please help!