views:

261

answers:

1

With Data Annotations for example, besides decorating members like this:

[Required(
    ErrorMessage = "You must enter your first name."
)]
public int FirstName { get; set; }

I can also do it like this to accommodate multiple cultures:

[Required(
    ErrorMessageResourceType = typeof(Resources.Customer),
    ErrorMessageResourceName = "NameRequired"
)]
public int FirstName { get; set; }

Does anybody know if the input builders in MVC Contrib support something like this for setting labels?

Thank you.

+1  A: 

In MVC 2 do you have an attribute called DisplayName. DisplayNameAttribute doesn't support localization out of the box, but you can derived it and implement it yourself.

Here is an example how to do that: http://adamyan.blogspot.com/2010/02/aspnet-mvc-2-localization-complete.html

Mendy
Thankfully the new DisplayAttribute class in .NET 4's DataAnnotations namespace takes care of this (http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.displayattribute.resourcetype(VS.100).aspx). Cool article BTW.
Daniel Liuzzi