I have set up a datepicker in a form using the following js:
$("#Expiry").datepicker({
regional: 'en-GB',
dateFormat: 'dd/mm/yy',
firstDay: 1
});
and have the following in my view (asp.net MVC)
<%: Html.TextBoxFor(m => m.Expiry) %>
In my model, Expiry is a nullable DateTime?
When I use the datepicker to choose a date it does so with the correct format
When I load data from the database it always displays with 00:00:00 at the end for the time portion
How can I get it to not do this?
If I try to use a formatting expression in my binding then it won't compile.
Surely jQuery should respect the formatting I've specified for values that are pre-loaded into the form field?
It does apply the datepicker to the field, so I can choose with a calendar. It just doesn't apply the formatting to the loaded value
any ideas?
$("Expiry")be$("#Expiry")?dateVal.substr(0,10)and set it when binding thetextboxto thedatepicker. Not an elegant solution, but got the job done.