RedirectToAction - potatoscript/asp.net.core.mvc GitHub Wiki
- Use RedirectToAction : action name, controller name, parameter
return RedirectToAction("ReloadTable",Controllerx, new { StartDate = StartDate, EndDate = EndDate, page = page });
- use Json : you need to supply onsubmit in the view
return Json(new { isValid = true, controllerx = Controllerx, startdate = StartDate, enddate = EndDate, page = page });
<form method="post" asp-action="Edit" onsubmit="return jQueryAjaxPost(this);">
function jQueryAjaxPost(form) {
try {
jQuery.ajax({
type: "POST",
url: form.action,
data: new FormData(form),
contentType: false,
processData: false,
success: function (res) {
if (res.isValid) {
jQuery("#form-modal .modal-body").html("");
jQuery("#form-modal .modal-title").html("");
jQuery("#form-modal").modal('hide');
if(res.controllerx=="Detail")
window.location.href = _url + res.controllerx + "/ReloadTable?StartDate=" + res.startdate + "&EndDate=" +res.enddate+"&td_tms_id="+ res.td_tms_id+"&taskname="+res.taskname;
else if (res.controllerx == "Master")
window.location.href = _url + res.controllerx + "/Index?StartDate=" + res.startdate + "&EndDate=" + res.enddate + "&page=" + res.page;
else
window.location.href = _url + res.controllerx + "/ReloadTable?StartDate=" + res.startdate + "&EndDate=" + res.enddate + "&page=" + res.page;
} else {
jQuery("#form-modal .modal-body").html(res.html);
}
},
error: function (err) {
console.log(err)
}
})
} catch (e) {
console.log(e);
}
// to prevent default form submit event
return false;
}