开发者

ASP.NET MVC 2 Display Name DataAnnotaion from Resource not working

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; }
    publ开发者_StackOverflow社区ic 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


http://weblogs.asp.net/rajbk/archive/2010/04/27/localization-in-asp-net-mvc-2-using-modelmetadata.aspx


must be like below ;

[Required(ErrorMessageResourceType = typeof(Resources), ErrorMessageResourceName = "Required")]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜