Hi
I want to Delete Record & then display message using NotifyJs & refresh Datatable
[HttpPost] public ActionResult Delete(string Id) { try { dbLocation.Delete(Id); } catch (Exception ex) { ExceptionLogging.SendExcepToDB(ex); } return RedirectToAction("Index"); }
*******************************************
$('body').on('click', '[id*=btnDelete]', function () { var data = $(this).parents('tr').find('td'); var Id = data.eq(0).html(); $("#hiddenId").val(Id); }); $('#btnConfirmDelete').click(function () { var Id = $("#hiddenId").val().replace(/\r?\n|\r/g, "").trim(); $.ajax({ url: "/Location/Delete", data: { Id: Id }, type: "POST", dataType: "json", success: function (result) { //$("#row_" + Id).remove(); //$('#tblLocation').DataTable().ajax.reload(); $('#DeleteModal').modal('hide'); clearTextBox(); $.notify(result.message, { globalposition: "top center", className: "success" }) }, error: function (errormessage) { alert(errormessage.responseText); } }); });
**************************************
<div class="modal fade" id="DeleteModal"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <a href="#" class="close" data-dismiss="modal">×</a> <h4 class="modal-title">Delete Record</h4> </div> <div class="modal-body"> <h5> Are you sure you want to Delete this Record ? </h5> </div> <div class="modal-footer"> @*<a href="#" class="btn btn-default" data-dismiss="modal">Cancel</a> <a href="#" class="btn btn-success" onclick="Delete()">Confirm</a>*@
<button data-dismiss="modal" type="button" class="btn btn-default">Cancel</button> <button id="btnConfirmDelete" type="button" class="btn btn-primary">Delete</button> </div> </div> </div> </div>
Thanks