Developing on ASP.net mvc 5, Bootstrap v3.3.7
In a Form I've a 'Date Of Calibration' field. I'm able to load bootstrap datetimepicker on this field on my Developing & Test machine. It's working fine there, but on the Live server the TextBoxFor date field doesn't show date inside it when the page loads. Once I click the textbox, datetimepicker appear and then the date gets rendered inside it.
I've also confirmed ViewModel does contain the date value when page is being loaded. It's just not getting rendered while page loads, and it only doing it on the production environment.
Any idea what could possibly be the reason
I'm loading Form inside a partial view in BootstrapModal.
@Html.TextBoxFor(model => model.date_of_calibration, new { id = "date_of_calibration", @class = "form-control" })
Loading datetimepicker as.
$(document).ready(function () {
$("#date_of_calibration").datepicker({ format: 'DD-MM-YYYY'});}
Also loaded the following scripts inside the my partial view
<script src="~/Scripts/bootstrap.min.js"></script>
<script src="~/Scripts/moment.min.js"></script>
<script src="~/Scripts/bootstrap-datetimepicker.min.js"></script>
<link href="~/Content/bootstrap-datetimepicker.min.css" rel="stylesheet" />
Update
So before I was loading the field in the model as model.date_of_calibration = DateTime.Now; changed it to = DateTime.Now.Date; which uses only the date component of DateTime Instance.
Now the date does show up in the field when the page loads. but its doing it wrong. Interchanging "Date & Month". i.e If the database record has 2017-12-05 00:00:00.000 (i.e. 5th Dec), it show 12-05-2017 (i.e. 12th of May) instead of 05-12-2017.
Now again it's only happening on the live environment.
jquery.min.jsfor one - Master Yodanew { id = "date_of_calibration" }- theTextBoxFor()has already added that attribute) - user3559349