Hi sir,
I want to delete a table row. Refresh the page even after delete the row
HTML:-
<input type="Delete" value="Create" class="btn btn-danger" onclick="DeleteSacrificialAnodePopUp('@Model.IstSacrificialAnodeListModel[i].UniversalIDTSacrificialAnodes','@Model.IstSacrificialAnodeListModel[i].UpdatedBy')" />
Model:-
public string UniversalIDTSacrificialAnodes { get; set; }
public string UpdatedBy { get; set; }
Controller:-
public ActionResult DeleteSacrificialAnode(string UniversalIDTSacrificialAnodes)
{
SacrificialAnodeModel objSacrificialAnodeModel = new SacrificialAnodeModel();
if (!string.IsNullOrWhiteSpace(UniversalIDTSacrificialAnodes))
{
SacrificialAnodeDTO objSacrificialAnodeDTO = new SacrificialAnodeDTO();
objSacrificialAnodeDTO.UniversalIDTSacrificialAnodes = UniversalIDTSacrificialAnodes;
objSacrificialAnodeDTO.UniversalIDTSacrificialAnodes = UniversalIDTSacrificialAnodes;
objSacrificialAnodeDTO.UpdateBy = SessionManager.CurrentUserProfile.UserID;
if (CMMS.common.ApplicationConfigConstant.IsCMMSApp)
{
ProxyFactory.Instance.TDryDockingProxy.DeleteSacrificialAnode(objSacrificialAnodeDTO)
}
}
TempData["DeleteMessage"] = "Dry docking delete sucessfully";
return RedirectToAction("SacrificialAnode");
}
Script:-
<script>
function DeleteSacrificialAnodePopUp(UniversalIDTSacrificialAnodes, UpdateBy)
var UniversalIDTSacrificialAnodes = $('#UniversalIDTSacrificialAnodes').val();
var model = $('#confirmModal');
var YOUR_MESSAGE_STRING_CONST = "Are you sure you want to delete the record?";
var CMMSurl = $("#CMMSWebSiteURL").val() + 'REFT/TDryDocking/DeleteSacrificialAnode?DeleteSacrificialAnodePopUp=' + DeleteSacrificialAnodePopUp;
$ajax({
type: "Get",
url: CMMSurl,
data: { "UpdateBy": UpdateBy, "UniversalIDTSacrificialAnodes": UniversalIDTSacrificialAnodes },
contentType: "application/json;charset=utf-8",
datatype: "json",
success: function (data) {
if (data.Result == 'success') {
ShowMessage(data.Message, 'Success');
$('#getAllTAsAndAs').html(data.AuxData);
firstPage();
}
var table = document.getElementById('text');
var RowCount = table.rows.length;
if (RowCount > '2') {
var row = table.deteleRow(RowCount - 1)
RowCount--;
}
}
})
</script>