0

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!

2 Answers 2

1

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.

Additionally, this creative idea (which also implements IDataErrorInfo) may be a help to you.

Sign up to request clarification or add additional context in comments.

Comments

0

Implement IDataErrorInfo on your model.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.