Hello everyone,
I am quite new to asp.net mvc, I am trying to display a bootstrap modal after I save the data. but its not showing modal or the modal disappears in a blink.
please see my code
thanks for the help in advance.
What I have tried:
controller action:
- [HttpPost]
- [ValidateAntiForgeryToken]
- public ActionResult AddNew(ProductModel pm)
- {
- if (ModelState.IsValid)
- {
- int result = IProductRep.Add(pm);
- if (result <= 0)
- {
- return HttpNotFound();
- }
- else
- {
- ViewBag.Saved = "saved";
- }
- }
- return View();
- }
view : (button is in the form with form method post)
- "submit" class="btn btn-primary float-right shadow" value="Save" data-toggle="modal" data-target="#exampleModal">
- @if (ViewBag.Saved != null)
- {
- class="modal fade" id="exampleModal">class="modal-dialog modal-dialog-centered">class="modal-content">class="modal-header">
class
="modal-title" id="exampleModalLabel">Modal title- ×
class="modal-body"> New product has been saved successfully.class="modal-footer"> Close Save changes - }
saan mughalPosted Mar 14, 2021, 5:59 PM
Sachin SinghPosted Mar 14, 2021, 2:14 PM
class
="modal-title">Modal titleNew product has been saved successfully.