In my previous post i gave example of client side validation. Also you need to localize error message. To do this you need to add resource file.Add resource file following way.
During creation of Student model you need to specify the resource.
public class Student
{
[Required(ErrorMessageResourceType = typeof(StudentResourse), ErrorMessageResourceName = "FirstNameError")]
[DisplayName("User name")]
public string FirstName { get; set; }
[Required(ErrorMessageResourceType = typeof(StudentResourse), ErrorMessageResourceName = "EmailError")]
[DisplayName("Email address")]
public string Email { get; set; }
[Required(ErrorMessageResourceType = typeof(StudentResourse), ErrorMessageResourceName = "PriceError")]
[DisplayName("Fees")]
public double Fees { get; set; }
}
Here you can see that ErrorMessageResourceType and ErrorMessageResourceName. This is used to identify resource file and resource name.
you need to create resource file for each culture you need. For example fr-FR.
As per the CurrentUICulture message is displayed.
No comments:
Post a Comment