0

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 validation) both validation summary display errors?

How can I handle this case????

2
  • Is there a reason for you keeping the Validation Summary in the Views? if it is being picked up in the _Layout I dont see why the View's Validation Summary Control is needed? Commented Aug 15, 2011 at 12:39
  • the partial view is login part so I want it as separated control with its validation and the other views to have its own validation and also both (view and login) included in separated forms Commented Aug 15, 2011 at 12:55

2 Answers 2

1

One suggestion:

Use nested layouts:

  1. _layout.cshtml: as usual. Use this for your login page.

  2. _layoutWithValidationSummary.cshtml: Uses _layout.cshtml as its layout, but adds a validationsummary. Use this as the layout for your other pages.

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

Comments

0

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?

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.