Validation Validationsummary in a modal receive Json message

Asked

Viewed 77 times

0

My application has a View Create which is opened through a modal and the Controller which was a Actionresult became a Jsonresult then return Json after the request [Httppost].

The [Required] Field Dataannotations work perfectly.

Except that in this change some validations of my old configuration have not worked anymore, being it mandatory.

These messages were captured by:

@Html.ValidationSummary(true, "", new { @class = "text-danger" })

How do I get Validationsummary to capture the message that is sent via Json

Examples of the return sent by my Controller Create.

return Json(new { resultado = true, mensagem = "Cadastro realizado com sucesso!" });
  • 1

    This will never work because the view is no longer loaded after the request. You will have to put this "Summary" manually after receiving the response from the server.

  • It’s really hit me today before I saw your answer, and you came to confirm, so thanks. What I will do is use the toastr for my messages, even if in some moments I have more than one warning message.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.