c# - How to show validation summary that corresponds exactly to the form submitted -
the same problem discussed in post: multiple forms in mvc view: modelstate applied forms.
i have followed along post , have several forms on same view, custom editor template, have created , registered custom model binder. here accompanying gist.
when use html.validationresultfor()
helpers in passwordeditorviewmodel.cshtml editor template desired results:
<li class="error">@html.validationmessagefor(i => i.oldpassword)</li> <li class="error">@html.validationmessagefor(i => i.newpassword)</li> <li class="error">@html.validationmessage("passwordchangeerror.wrongpassword")</li>
this code returns validation errors form i've posted.
on other hand when use html.validationsummary()
helper in same editor template validation result propagated across forms despite fact i've posted one:
is normal behavior? or have missed in code?
when using @html.validationsummary, not remember posted, , submit button. way have handled in past having
<input type="submit" value="button1" /> @if (request["button1"] != null) { @html.validationsummary() } <input type="submit" value="button2" /> @if (request["button2"] != null) { @html.validationsummary() }
Comments
Post a Comment