I want to format the title of my Validation Summary using a string something like:
"There are {0} errors on this page."
How do I find out the number of errors without doing it in the controller and adding it to View Data?
I assume you mean from the view. The following is untested.
ViewData.ModelState.Values.Where( v => v.Errors.Count != 0 ).Count()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With