DisplayName attribute from Resources?

Posted by Palantir on Stack Overflow See other posts from Stack Overflow or by Palantir
Published on 2010-03-12T08:25:22Z Indexed on 2010/03/12 8:27 UTC
Read the original article Hit count: 248

Filed under:
|

Hello! I have a localized application, and I am wondering if it is possible to have the DisplayName for a certain model property set from a Resource.

I'd like to do something like this:

public class MyModel {
  [Required]
  [DisplayName(Resources.Resources.labelForName)]
  public string name{ get; set; }
}

But I can't to it, as the compiler says: "An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type" :(

Are there any workarounds? I am outputting labels manually, but I need these for the validator output!

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about asp.net-mvc-2