如何根据按下按钮的提交值更改 AjaxOptions 的值。
在视图中:
@using (Ajax.BeginForm("function_name", "Controller",
new AjaxOptions
{
HttpMethod = "POST",
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "resultsLoad",
OnBegin = "function_onBegin",
OnFailure = "function_onFailure",
OnSuccess = "function_onSuccess",
OnComplete = "function_onComplete"
})) {
<button type="submit" id="btn_1" value="submit1" name="submit"></button>
<button type="submit" id="btn_2" value="submit2" name="submit"></button>
}
在控制器中:
[HttpPost]
public ActionResult function_name(IndexViewModel model, string submit)
{
enter code...
return PartialView();
}
当我通过按下任何按钮发布时,我需要在返回新的 PartialView 之前更改 AjaxOptions 值。