HI
ISActive value is shown as false though i have clicked CheckBox.
What should be the Controller . I want if succes then message should appear using NotifyJS & DataTable should be refreshed.
If error then Modal Popup should remain open.
*********************************************************
public JsonResult Add(Location objLocation)
{
if (ModelState.IsValid)
{
dbLocation.Add(objLocation);
return Json(new { success = true, message = "Successfully Saved" });
}
return Json(objLocation);
}
***************************************
function Add() {
//var res = validate();
//if (res == false) {
// return false;
//}
//alert("in");
var objLocation = {
Id: $('#txtId').val().toUpperCase(),
Description: $('#txtDescription').val().toUpperCase(),
IsActive : $('#IsActive').val()
};
***************************
@foreach (var item in Model)
{
@Html.DisplayFor(modelItem => item.Id)
@Html.DisplayFor(modelItem => item.Description)
@Html.DisplayFor(modelItem => item.IsActive)
Edit
}
****************************************
$.ajax({
url: "/Location/Add",
data: JSON.stringify(objLocation),
type: "POST",
contentType: "application/json;charset=utf-8",
dataType: "json",
success: function (data) {
//$.notify(data.message, {
// globalposition: "top center",
// //position:"center",
// className: "success"
//})
$('#myModal').modal('hide');
},
error: function (xhr, ajaxOptions, thrownError) {
alert("Error");
}
});
}
Thanks
Sachin SinghPosted Jun 8, 2021, 7:55 PM