im using c# mvc5 my delete not working see my code.
- public ActionResult Delete(int id)
- {
- var shipmentItem = _shipmentItemService.Get(id);
- _shipmentItemService.Remove(shipmentItem);
- return RedirectToAction("shipmentlistmodel");
- }
this is my view script
- $(function () {
- $('#ShipmentItemList').DataTable({
- "ajax": "@Url.Action("getshipmentitemlist", "shipment")?shipmentId=" + @ViewBag.ShipmentId,
- "columns": [
- { "data": "ShipmentName" },
- { "data": "PackageNumber" },
- { "data": "TrackingNumber" },
- { "data": "ClientName" },
- { "data": "Status" },
- {
- "render": function (data, type, full, meta) {
- return "<a href='#' class='btn btn-danger' onclick=DeleteData('" + full.id + "'); >Delete</a>";
- }
- }
- ]
- });
- });
-
- function DeleteData(id) {
- if (confirm("Are you sure you want to delete..?")) {
- Delete(id);
- }
- else {
- return false;
- }
- }
-
- function Delete(id) {
- var del = "@Url.Action("delete", "shipment")?id=" + id;
- $.post(del, { id: id }, function (data) {
- if (data == "Deleted") {
- alert("Delete Customer !");
- Table = $('#ShipmentItemList').DataTable();
- Table.draw();
- }
- else {
- alert("Something Went Wrong!");
- }
- });
- }