ASP.NET-MVC-2 – ASP.NET MVC 2 Display Name DataAnnotion from Resource Can’t work properly

I am trying to use resource files to save the label text of the model in an MVC 2 project.

I have the following courses…

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

……and tried to use……

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

…but I got the “FirstName” of the label in all instances. The resource file is named Labels.resx, has an entry of “First”, and is located in the Properties folder.

Read a few After this article, I believe this should apply to .NET 4 (I am using VS2010 RTM and have targeted .NET 4).

Is this useful?

Thanks in advance

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

I am trying to save the model in an MVC 2 project using resource files

I have the following courses…

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

…and tried to use…

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

…but I get the label’s “FirstName” in all instances. The resource file name is Labels.resx, with the “First” entry, is located in the Properties folder.

After reading a few articles, I believe this should work for .NET 4 (I am using VS2010 RTM and have targeted. NET 4).

Is this useful?

Thanks in advance

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

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2117 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.