[英]disable redirect after submit form
我有表格
@using (Html.BeginForm("ActionName", "ControllerName", FormMethod.Post)) {
...
<input type="submit" />
}
當我提交此表單時,我將重定向到/ ControllerName / ActionName。 如果這樣添加onsubmit我可以停止
@using (Html.BeginForm("ActionName", "ControllerName", FormMethod.Post, new {onsubmit="return Submit();"}))
和這樣的腳本
Submit = function() {
...
return false;
}
有沒有防止自定義腳本重定向的正確方法嗎?
UPD:服務器端代碼
[HttpPost]
public JsonResult MySubmit(ParamsClass params)
return new JsonResult {
Data = BusinessLogicOperations();
};
}
修改您的帖子操作:
[HttpPost]
public ActionResult MySubmit(ParamsClass params)
// do your busines logic here
return RedirectToAction("YourAction", "YourController", params);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.