Hi,
I have a strongly typed view model. I'm using MVC 2 and EF4. When I click the submit button, front end validation passes and it goes into my Create action, and for some or other reason my ModelState is false. Not sure why. So I added the following line of code to see the errors:
foreach (var modelStateValue in ViewData.ModelState.Values)
{
foreach (var error in modelStateValue.Errors)
{
// Do something useful with these properties
var errorMessage = error.ErrorMessage;
var exception = error.Exception;
}
}
It goes in the var errorMessage = part for every property that has a data annotation set to it. How can this still be false if client validation passed?
Thanks.