Views: 13.1K
Replies: 1
Archived
|
Localization for [Required(...)] attributeThe CustomerModel class has ErrorMessages for Required and StringLength attributes that are hardcoded english strings.
/// <summary> /// Customer Model class. /// Properties have data annotations used for Validation and Display. /// </summary> public class CustomerModel { /// <summary> /// The Customer Identifier. /// </summary> [DisplayName("Id")] public int CustomerId { get; set; } /// <summary> /// Customer Company name. /// </summary> [DisplayName("Company Name")] [Required(ErrorMessage = "Company Name is required.")] [StringLength(30, ErrorMessage = "Company Name can be at most 30 characters")] public string CompanyName { get; set; } } M S, Sep 08, 2010
|
|
Reply 1Localization is a fairly large topic, but essentially it is supported throughout .NET. As such, the Design Pattern Framework supports localization.
To get the errormessage to display in a different language you need something like this: [Required(ErrorMessageResourceType = typeof(Resources.Errors), ErrorMessageResourceName = "CompanyName_Required")] Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr"); http://forums.asp.net/p/1433699/3264915.aspx I hope this gets you going. Dan McMillan, Sep 10, 2010
|