tags:

views:

504

answers:

3

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!

A: 

Implement IDataErrorInfo on your model.

Craig Stuntz
A: 

any one tell me how i will use validation summery in asp.net please send me the step by step procedure '

-1 this is not an answer.
Myster
A: 

This tutorial is a good example of the IDataErrorInfo technique - it makes adding validation parameters easy by adding them as attributes directly to the properties of the model classes.

These examples also may help - slightly different approaches to validating.

cottsak