How to use and/or localize DisplayAttribute with ASP.NET MVC2?

Posted by asp_net on Stack Overflow See other posts from Stack Overflow or by asp_net
Published on 2010-03-25T16:45:20Z Indexed on 2010/03/25 18:43 UTC
Read the original article Hit count: 939

I am trying to figure out how to get the DisplayAttribute in my MVC 2 ViewModel to work with the Html.LabelFor() helper.

Neither

public class TestModel
{
    [Display(ResourceType = typeof(Localization.Labels))]
    public string Text { get; set; }
}

nor

public class TestModel
{
    [Display(Name = "test")]
    public string Text { get; set; }
}

seem to work. Localizing the Required Attribute works as expected:

[Required(ErrorMessageResourceName = "Test", ErrorMessageResourceType = typeof(Localization.Labels))]

I am using VS2010 RC. Has anybody got that running?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about asp.net-mvc-2