ASP.NET MVC Class level custom data-annotation and ModelState keys
Posted
by Neil
on Stack Overflow
See other posts from Stack Overflow
or by Neil
Published on 2010-04-10T12:06:44Z
Indexed on
2010/04/10
12:13 UTC
Read the original article
Hit count: 742
ASP.NET
|asp.net-mvc
Hi,
I have custom class level validation attribute, inheriting from ValidationAttribute, on my model.
How come it doesn't register a key in the ModelState when its IsValid is false? I can see the the error message in the ModelState.Values collection, but the ModelState.Keys collection only shows an empty string "". Can I provide a key for it - presumably this is because its not assigned to a property?
I wanna be able to use ModelState.Remove in my controller to remove this error upon a certain condition, but I have no Key!
Any ideas?
© Stack Overflow or respective owner