How to handle multiple validationsummary in mvc3
I have partial view with its validation summary that must displayed with all views (I put it in the _Layout file) and in some views there is also validation summary.
So, when validate any view(doing server validatio开发者_StackOverflow社区n) both validation summary display errors?
How can I handle this case????
One suggestion:
Use nested layouts:
_layout.cshtml: as usual. Use this for your login page.
_layoutWithValidationSummary.cshtml: Uses _layout.cshtml as its layout, but adds a validationsummary. Use this as the layout for your other pages.
I think you can only have one Validation summary, as you have seen more than one will cause duplications of errors.
I've tried looking to see if it is possible to assign certain validation errors to a specified Validation Summary, but I dont think this is possible.
You might need to look at an alternative solution. Not going as far as creating your own validation engine it might be possible passing something back in the ViewBag
instead of using the validation summary for any of your Login errors?
精彩评论