2
I have my registration, which was done using Scallfold’s visual studio In my view:
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-actions no-color">
<input type="submit" value="Delete" class="btn btn-danger" /> |
</div>
}
And on my controller:
public ActionResult DeleteConfirmed(string id)
{
Cliente cliente = db.Clientes.Find(id);
db.Clientes.Remove(cliente);
db.SaveChanges();
return RedirectToAction("Index");
}
How do I validate the deletion if there is already registration with this client? How to return to View using html helper?
No error message in view...
– Rod
@Rod You put the
@Html.ValidationSummary(true)
?– Leonel Sanches da Silva
I think I told you nonsense. The
@Html.ValidationSummary(true)
it has to be inside theHtml.BeginForm
.– Leonel Sanches da Silva
Exactly this way, does not appear msg in the View, I even tried with Validationmessage("Error") also does not appear
– Rod
@Rod I reviewed some things and the
RedirectToAction
does not consider the validation result. I updated my answer.– Leonel Sanches da Silva