我在控制器中使用BeginForm()
方法有一个表单提交方法,但在同一方法中,我还在_Layout.cshtml
页面上的提交按钮上有点击事件。目前,第一次点击事件被触发,然后调用BeginForm()
方法。
那么,如何在提交按钮点击事件之前先调用BeginForm()
方法?
提交按钮点击事件:(_Layout.cshtml
)
$("#SaveData").click(function (b) {
debugger
var list = new Array();
var postData;
$('input.chkevent').each(function () {
debugger
if (this.checked == true) {
var parent_id = this.parentElement;
var par2 = parent_id.previousElementSibling;
var par3 = par2.previousElementSibling;
var child = par3.childNodes[0];
var child_val = child.defaultValue;
var arr_date = this.parentElement.nextElementSibling.childNodes[0].value;
var dep_date = this.parentElement.nextElementSibling.nextElementSibling.childNodes[0].value;
var id = new Array(); ;
id.push(child_val, arr_date, dep_date);
list.push(id);
postData = { values: list};
}
});
$.ajax({
url: '@Url.Action("FormData", "HomeSurface")',
//jQuery.ajaxSettings.traditional = true
// url: "CheckEvent/PersonEvent?id=" + allVals,
data: postData,
type: "POST",
traditional: true,
// dataType: "json",
// traditional: true,
success: function () {
}
});
});
Submit_Form(Index.cshtml):
@using (Html.BeginUmbracoForm<HomeSurfaceController>("FormData"))
{
<fieldset>
</fieldset>
}
在控制器中:
public ActionResult FormData(PERSON_MASTER person, string[] values)
{
}