asp.net MVC+EasyUI用 Form Post 提交数据失败 Control不能接到数据
本人初学MVC 和EasyUI,做个信息采集页面,用Form Post 提交,后台Controller 却获得不到Requet数据?
AddInfo.cshtml
<div id="dlgAdd" class="easyui-dialog" style="" closed="true" buttons="#dlgAdd-btns">
<form id="frm" method="post" action="@Url.Action("Save")" >
<table id="GridData" class="easyui-datagrid" style="width:1000px;height:300px" data-options=" ">
<thead>
<tr>
<th data-options="field:'id',width:30">编号</th>
<th data-options="field:'bigclass',width:100,editor: { type: 'combobox', options: { required: true, editable: false, data : [{ 'id': '1', 'text': '优盘' },{ 'id': '2', 'text': '移动硬盘' },{ 'id': '3', 'text': '其他设备' }],valuefield: 'value', textfield: 'text' } }">大类</th>
<th data-options="field:'devicename',width:100,haign:'center',align:'left', editor: { type: 'text', options: { required: true } }">设备名称</th>
<th data-options="field:'model',width:100,align:'left',editor: { type: 'text', options: { required: true } } ">规格型号</th>
<th data-options="field:'number',width:100,align:'right',editor: { type: 'text', options: { required: true } }">数量</th>
<th data-options="field:'numunit',width:100,align:'right', editor: { type: 'combobox', options: { required: true, editable: false, data : [{ 'id': '1', 'text': '个' },{ 'id': '2', 'text': '只' },{ 'id': '3', 'text': '盒' }], valuefield: 'value', textfield: 'text' } }">数量单位</th>
<th data-options="field:'useperson',width:100,align:'left',editor: { type: 'text', options: { required: false } }">直接使用人</th>
<th data-options="field:'remark',width:100,align:'left',editor:'text'">备注</th>
@*<th data-options="field:'applydate',width:100,align:'left',editor:'text'">申请日期</th>
<th data-options="field:'apply',width:100,align:'left',editor:'text'">申请人</th>
<th data-options="field:'depart',width:100,align:'left',editor:'text'">申请单位</th>*@
</tr>
</thead>
<tr>
<td>
<div id="dlgAdd-btns">
<a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-add" plain=true onclick="Save()">保存 </a>
<a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-redo" plain=true onclick="Cancel()">取消</a>
</div>
</td>
</tr>
</table>
</form>
</div>
<script type="text/javascript">
function Add() {
$('#dlgAdd').dialog('open').dialog('setTitle', '添加');
initTable();
}
function Save() {
$('#frm').form('submit', {
//$.ajax({
url: '/BasicLevelUnitManage/Save',
type: 'POST',
dataType: 'json',
data: $('#frm').serializeObject(),
//data: [{
// "bigclass": $("#frm combox[name=bigclass]").val(),
// "devicename": $("#frm input[name=devicename]").val(),
// "model": $("#frm input[name=model]").val(),
// "num": $("#frm input[name=num]").val(),
// "numunit": $("#frm input[name=numunit]").val(),
// "useperson": $("#frm input[name=useperson]").val(),
// "remark": $("#frm input[name=remark]").val()
//}],
onSubmit: function () {
//console.log(jsonuserinfo);
//alert(JSON.stringify(jsonuserinfo));
//return $(this).form('validate');
},
success: function (data) {
//var result = eval('(' + result + ')');
alert("success:" + data);
//if (result.errorMsg) {
// $.messager.show({
// title: 'Error',
// msg: result.errorMsg
// });
// $('#dg').datagrid('reload'); // reload the user data
//} else {
// $.messager.show({
// title: '创建成功',
// msg: result.okMsg
// });
// $('#dlgAdd').dialog('close'); // close the dialog
// $('#dg').datagrid('reload'); // reload the user data
//}
}
});
}
</script>
控制器方法
public class BasicLevelUnitManageController : Controller
{
[HttpPost]
public ActionResult Save()
{ if ((Request.Form["bigclass"] != null)&&(Request.Form["model"] != null))&&(Request.Form["devicename"] != null))
{
string bigclass = Request.Form["bigclass"].ToString();
string model = Request.Form["model"].ToString();
string devicename = Request.Form["devicename"].ToString();
}
return Content("OK :" + "-");
}