views:

671

answers:

2

Hi,

I'm trying to use a resource file to hold label text for the Model in an MVC 2 project.

I've got the following class...

public class Person
{
    [Display(ResourceType = typeof(Resources.Labels),Name="First")]
    public string FirstName { get; set; }
    public string LastName { get; set; }
}

...and have tried using...

    <%: Html.EditorForModel() %>
    <%: Html.EditorFor(m => m) %>
    <%: Html.LabelFor(m => m.FirstName) %>

...but I'm getting "FirstName" for the label in all instances. Resource file is called Labels.resx, has an entry for "First" and is in Properties folder.

Having read a few posts, I believe this should work in .NET 4 (I'm using VS2010 RTM and have targetted .NET 4).

Should this work?

Thanks in advance

A: 

must be like below ;

[Required(ErrorMessageResourceType = typeof(Resources), ErrorMessageResourceName = "Required")]
Sefer KILIÇ