Custom validation summary

Posted by Robert Morgan on Stack Overflow See other posts from Stack Overflow or by Robert Morgan
Published on 2009-02-04T18:54:00Z Indexed on 2010/05/23 13:00 UTC
Read the original article Hit count: 276

Filed under:

I'm using the UpdateModel method for validation. How do I specify the text for the error messages as they appear in the validation summary?


Sorry, I wasn't entirely clear. When I call UpdateModel(), if there is parsing error, for example if a string value is specified for a double field, a "SomeProperty is invalid" error message is automatically added to the ModelState.

How do I specify the text for said automatically generated error message?

If I implement IDataErrorInfo as suggested, it's error message property gets called for every column, regardless of whether the default binder deems it valid or not.

I'd have to reimplement the parse error catching functionality that I get for free with the default binder.

Incidentally, the default "SomeProperty is invalid" error messages seem to have mysteriously dissappeared in the RC. A validation summary appears and the relevant fields are highlighted but the text is missing! Any idea why this is?

Thanks again and I hope all this waffle makes sense!

© Stack Overflow or respective owner

Related posts about asp.net-mvc