JS代码:
var createDistricts = {
title: 'Add district',
Url: params.urlCreateDistrict,
data: {
provinceId: provinceId
},
width: 600,
buttons: [
{
text: '<span class="glyphicon glyphicon-ok"</span Add',
class: 'btn close',
eventHandle: function () {
$(params.formAdd).submit();
},
},
{
text: '<span class="glyphicon glyphicon-remove"</span Cancel',
class: 'btn',
eventHandle: function () {
$('#dialogHIA').modal('hide');
},
}
]
};
cm.ShowDialog(createDistricts);
}
控制器:
[HttpPost]
public ActionResult CreateDistrict(HsmDistrict model, int? provinceId)
{
//model.ProvinceId = provinceId;
model.CreatedBy = _userId;
int checkFirst = _service.CheckComplic(model.DistrictId, "DistrictId", model.NativeName, "NativeName", "HsmDistrict");
int checkSecond = _service.CheckComplic(model.DistrictId, "DistrictId", model.InternationalName, "InternationalName", "HsmDistrict");
int checkThrid = _service.CheckComplic(model.DistrictId, "DistrictId", model.DistinctName, "DistinctName", "HsmDistrict");
if (checkFirst == -1 || checkSecond == -1 || checkThrid == -1)
{
ModelState.AddModelError("", "It's exist!");
return PartialView("_CreateDistrict", model);
}
_service.CreateDistrict(model);
return PartialView("_CreateDistrict", model);
}
从JS到Controller的valueId值为空。