function RaceDate_onChange() {
var pickedDate = $(this).data('tDatePicker').value();
var month = pickedDate.getMonth() + 1;
$.get("/RaceCard/Details?year=" + pickedDate.getFullYear() + "&month=" + month + "&day=" + pickedDate.getDate());
}
@Html.Telerik().DatePickerFor(model => model.RaceDate).ClientEvents(events => events.OnChange("RaceDate_onChange"))
[HttpGet]
public ActionResult Details(int year, int month, int day)
{
var viewModel = new RaceCardModel { Metadata = DetailModelMetadata.Display, RaceDate = new DateTime(year, month, day) };
var raceCard = _raceCardService.GetByRaceDate(viewModel.RaceDate) ?? new RaceCard { RaceDate = DateTime.Now };
viewModel.MapFromEntity(raceCard);
return View(viewModel);
}
In the above JavaScript even handler, Telerik MVC DatePicker, and controller action respectively, i
n GET requests to the Details action, the day value is always one day behind the DatePicker. E.g. The first value is set from a view model property, when the view is rendered, say 3. I then click on 14 and hit my breakpoint in the action method. The day value is 3. When I click on 29 and hit the breakpoint, the day value is 14.