I have date-time picker that is bound to a datetime property on my view-model. when I select the date from date-time picker and I post back, it binds the value to the model, but when I try to set the value through jequery, the value is always null.
my model is:
public class viewmodel
{
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
public datetime DDate { get; set; }
}
and the view code is
<div class="col-md-3">
@Html.TextBoxFor(m => m.DDate, new {@class = "form-control datepicker" })
@Html.ValidationMessageFor(model => model.DDate, "", new { @class = "text-danger" })</div>
javascript code is
$("#DDate").datepicker({ dateFormat: 'dd/mm/yy' });
so when I click an option button it sets the date of the datetime picker
$(':input[id="rbVatVoluntary"]').click(function () {
var thDate = $("#DDate");
thDate.attr("disabled", 'disabled');
thDate.datepicker('setDate', new Date());});
When I check the console in the browser, I see that the value is set correctly but when I post the form and check the model property, it is null.
I appreciate any help on this