Hello I've got a model of USER and for example the property FIRSTNAME IS REQUIRED AND MUST BE BETWEEN 2 and 50 characters. That's why I use data annotation and the field FirstName in my class looks like :
public class User
{
[Required(ErrorMessage = "{0}" + GETMESSAGEFROMDATABASE();)]
[Range(typeof(int), "0", "100", ErrorMessage = "{0}" + GETMESSAGEFROMDATABASE();)]
public string FirstName { get; set; }
...........................
}
The problem is when I post the data and the Modelstate is not valid and I'm returned again in Register page I want to give custom error messages for each of the errors and the text should be get from a function; Please don't ask why I - just accept that I've got no other choice.
SO I want my validation summary to look like this :
*Name of the field : custom message for the error get from function
*Name of the field : custom message get from function