@using (Html.BeginForm())参数示例
原文链接:https://www.cnblogs.com/firstcsharp/p/3238321.html
-
指定表单提交方式和路径等
@using (Html.BeginForm("Index", "Home", FormMethod.Get, new { name = "nbform", id = "nbform" }))
-
指定表单提交为数据方式
@using (Html.BeginForm("ImportExcel", "Stock", FormMethod.Post, new { enctype = "multipart/form-data" }))
-
下面的操作可以防止提交链接后面自带参数
@using (Html.BeginForm("AddDIYBillOfLading", "BillOfLading", new { id ="" }, FormMethod.Post, new { name = "myform", id = "myform" }))
操作实例 :
cshtml:
@using (Html.BeginForm(“New”, “Account”, FormMethod.Post, new { @id = “form1”, enctype = “multipart/form-data” }))
New: 后台提交事件
Account: Controller
控件:
给控件关联事件
SubmitAccount(“btnSave”, “form1”, “/B2C/Account/New”, “保存成功”, true, beforeFun, afterFun);
$.ajax()方法
function 函数名() {
var url = “/文件夹/controller名称/后台事件名称”;
$.ajax({
cache: false,
type: “POST”,
url: url,
data: $(’#form1’).serialize(), // $(’#’ + form).serialize(), // 要提交的表单,必须使用name属性
beforeSend: function () {
LockSubmit(true, pwdReset);
},
success: function (success) { // msg 弹出信息,success 成功信息,reset 是否重置标识, true 是否关闭窗口
//ShowMsgDialogAndCloseWin(msg, success, reset, false);
//ShowMsgDialog_F(msg, success, reset, false);
// $(this).dialog(dialog_F_test);
alert(msg);
LockSubmit(false, pwdReset);
clear();
},
error: function (xhr, status, error) {
var errs = ParseExceptionMsg(xhr);
ShowMsgDialog(errs, "no", false);
LockSubmit(false, pwdReset);
},
complete: function () {
LockSubmit(false, pwdReset);
}
});
后台control 事件
public async Task New(FormCollection form, BANKACCOUNTDto model)
参数 :FormCollection form, BANKACCOUNTDto model