views:

2

answers:

0

hey,

I created a class that implements the IModelBinder interface. Within a method of that class I basically retrieve some values and try to validate them. If the validation fails, I add update the model state with necessary information like below:

        DateTime mydate;
        if (!DateTime.TryParse(convValue,out mydate))
        {
            bindingContext.ModelState.AddModelError("Date", "Date was crap");
        }

The problem is that Html.ValidationMessageFor(m => m.Model) returns no value. I looked at the MVC source code and found out that a proper key with id "Date" can't be found in the ModelState dictionary.

Why is that ? The controller that returns the view have access to the model state and can enumerate over ModelState.Errors

Thanks, Thomas