-2

I have a partial view in a layout file, my partial view has a form and some server side validation. when my form is submitted and modelstate is invalid what should I return?

something is bold here:

1) I don't want to use javascript

2) I want to show modelstat errors in client side

Thanks :)

Saeed Hamed
  • 732
  • 2
  • 10
  • 28

2 Answers2

0

You should add @Html.ValidationSummary() in that place, where you want to display your errors

Maxim Zhukov
  • 10,060
  • 5
  • 44
  • 88
0

If you want it to behave like a partial view:

return PartialView();

This posts the original model back with the current model state. You can use @Html.ValidationSummary() to display the errors as stated by @FSou1.

Henk Mollema
  • 44,194
  • 12
  • 93
  • 104