views:

142

answers:

1

So, the partial view is a form, that is revealed via a jQuery show(). The form is submitted, and suppose a unique index is violated, for example, using the Post-Redirect-Get pattern I pass the errors via TempData back to the original view, which contains the partial view that is of course hidden again. Therefore the form's errors/hints/original data is not visible.

What is the most efficient way of presenting/revealing this partial view's form, with error message(s)?

+1  A: 

Try not redirecting in case of error. If the ModelState is invalid simply return the same view. Then in the view you could display the form. If you want to continue using the Post-Redirect-Pattern you could store the ModelState into TempData as shown in this blog post and a nice implementation here.

Darin Dimitrov
Thanks for the links. That custom filter is actually almost exactly how I did it, and as I understood it, helps avoid certain problems. I've been thinking about it, and the only time I wouldn't be able to handle it properly, is when they have javascript disabled; this means the form won't be using show() in the first place, and I'll need a separate implementation anyway.
PolishedTurd