I try to use implement bootstrap v3 datetimepicker in my mvc project but its not working. below is my editor templates.
@model DateTime?
@Html.TextBox("", Model.HasValue ? Model.Value.ToString("d") : String.Empty)
$(function() {
// target only the input in this editor template
$('#datepicker').datetimepicker();
}); </script>
i had inculded bootstrap datetimepicker script on my _layout.chtml but seem like it cant function
<script src="~/Scripts/bootstrap-datetimepicker.js"></script>
<script src="~/Scripts/bootstrap-datetimepicker.min.js"></script>
this is my view
@Html.LabelFor(model => model.EndDate, new { @class = "control-label col-md-2" }) @Html.EditorFor(model => model.EndDate)
@Html.ValidationMessageFor(model => model.EndDate) </div> </div>
It only come out as normal datetimepicker if i set it as
[DataType(DataType.Date)]
public DateTime EndDate { get; set; }
@Html.EditorFor(model => model.EndDate)
generates an textbox withid="EndDate"
. Your script is targeting an element withid="datepicker"
– user3559349