我在index.cshtml中有代码
@using (@Ajax.BeginForm("ActionEvent", "Fielding", new AjaxOptions { OnSuccess = "onBDSuccessFunction", HttpMethod = "post" }, new { id = "frmField" }))
{
@Html.Partial("../Fielding/_CreateOrEdit", Model)
}
和_CreateOrEdit
function onBDSuccessFunction(result, status, xhr) {
var errorMessage = '';
switch (String(result.Result).toUpperCase()) **2 cases from controller when Actionevent Method fired** {
case "OK":
var _msg = "Data Saved Successfully";
alert(_msg);
return true; **saved data into database only happens here**
break;
case "ERROR":
if(result.Message=='1')
{
alert(result.Messag);
return false; **prevent submiting form here**
}
}
}
这里我有两个案例来自ActionEvent Method Case OK和Case ERROR它将结果返回为Json
但是在这两种情况下数据都保存到数据库中..但验证已激活消息显示正确.. 我能为此做些什么..请指导我..