First, I have 3 input text box (day, month, year). I made Json return from my controller and I made a key & value binding function with jquery. The problem is I don't know how to split Datetime value into day, month, year and bind to my inputs because that Datetime value is looks like
EntryDate: "/Date(940786200000)/"
My Controller
[HttpGet]
public ActionResult getBookById(int? id)
{
TB_EnglishBooks tbook = db.TB_EnglishBooks.Where(x => x.ItemID == id).FirstOrDefault();
return Json(tbook, JsonRequestBehavior.AllowGet);
}
My Html View
<input class="form-control" id="Day" type="text" placeholder="Day" style="width: 94px;">
<input class="form-control" id="Month" type="text" placeholder="Month" style="width: 94px;">
<input class="form-control" id="Year" type="text" placeholder="Year" style="width: 94px;">
My Binding Function
function bindcontrol(data) {
$.each(data, function (key, value) {
$("#mymodal").modal('show');
if (value == true || value == false) {
$("#addform").find("input[type='checkbox'][name='" + key + "']").prop("checked", value);
}
else {
$("#addform").find("input[name='" + key + "']").val(value);
$("#addform").find("textarea[name='" + key + "']").val(value);
$("#addform").find("select[name='" + key + "']").val(value);
}
})
}