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 - }

Sachin SinghRank #66 · 26.2K reputationPosted Mar 14, 2021, 10:14 AM EDT
class
="modal-title">Modal titleNew product has been saved successfully.
saan mughal14 reputationPosted Mar 14, 2021, 1:59 PM EDT