Thursday, August 23, 2018

Customize the Error Message in ASP.NET MVC

Add the following keys into Application_Start() at Global.asax
ClientDataTypeModelValidatorProvider.ResourceClassKey = "YourResourceName";
DefaultModelBinder.ResourceClassKey = "YourResourceName";
Create YourResourceName.resx inside App_GlobalResources folder and add the following keys
FieldMustBeDate The field {0} must be a date.
FieldMustBeNumeric The field {0} must be a number.
PropertyValueInvalid The value '{0}' is not valid for {1}.
PropertyValueRequired A value is required.

No comments:

Post a Comment