ASP.NET MVC Validation - localisation of the error string
Posted
by gmang
on Stack Overflow
See other posts from Stack Overflow
or by gmang
Published on 2010-04-13T16:49:40Z
Indexed on
2010/04/13
16:53 UTC
Read the original article
Hit count: 532
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!
© Stack Overflow or respective owner