I work with ASP.NET MVC 4 and I have an issue with bootstrap modal. I have a modal with a form containing 4 DropDownList (in a partial view), when I submit the form the action check in the database if the reference exist.
I want to display an alert in the modal if the reference doesn't exist without leaving the modal, please tell me if this is possible and how ?
This is a part of my view
@using (Html.BeginForm("AfficherBobine", "Home"))
{
<div class="modal fade" id="ChoisirBobine" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<div class="container-fluid">
<section class="row">
@Html.Partial("PartialFormBobine")
</section>
<section class="row">
</section>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Fermer</button>
<button type="submit" class="btn btn-default">Envoyer</button>
</div>
</div>
</div>
</div>
}
And this is the code of the action :
[HttpPost]
public ActionResult AfficherBobine(string annee, string semaine, string montage, string numero)
{
string arg = annee + semaine + montage + numero;
IDal dal = new Dal();
//this is the code to check if the reference exist
SortedList arg_Params = new SortedList();
arg_Params.Add("NUM_BOBINE", arg);
List<CheckIdentite> Bobine = dal.RetourneIdentite(ref arg_Params);
if (Bobine.Count != 0)
{
return RedirectToAction("Index", new { id = arg });
}
else
{
//Here the code to show an alert ("Wrong selection")
}
}
Thanks for your attention