I am calling Delete controller method from ajax on button click but when i click the button it gives error like "Object reference not set to an instance of an object."
I have write a code for the ajax and calling delete method previously the javascript code get called on every page load rather than on button click but then i add e.preventDefault(); The issue is now it is giving error rather then moving to the controller delete method.
My Javascript code
- [httppost]
- public ActionResult Delete(int? id) { if (id == null)
- { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } S
- tudent_Experience student_Experience = db.Student_Experience.Find(id);
- if (student_Experience == null) { return HttpNotFound(); }
- // Student_Experience student_Experience = db.Student_Experience.Find(id);
- db.Student_Experience.Remove(student_Experience);
- db.SaveChanges(); return RedirectToAction("Create","Students"); // return View(student_Experience); }
Jaimin ShethiyaPosted Nov 8, 2019, 3:41 AM
can you please update your javascript code same as the below and after check it worked or not.
Thanks
Salman BegPosted Oct 25, 2019, 2:59 AM
Mark TaborPosted Oct 25, 2019, 2:32 AM
Salman BegPosted Oct 25, 2019, 2:21 AM