Reputation: 35
This the html page that not work the problem with NewspostedDate
<div class="form-group">
@Html.LabelFor(model => model.NewsPostedDate, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.NewsPostedDate, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.NewsPostedDate, "", new { @class = "text-danger" })
</div>
</div>
Upvotes: 0
Views: 470
Reputation: 1021
instead of Editorfor you can use TextBoxfor.
try this
@Html.TextBoxFor(m => m.NewsPostedDate, new { @class = "form-control date-picker" })
$('.date-picker').datepicker({ format: "yyyy/mm/dd", autoclose: true })
Note: Good approach first load you css file , then load javascript/jquery . because user first see you UI , then interact with your UI
Upvotes: 1
Reputation: 784
Looks like your Editorfor is missing the class "NewsPostedDate" or perhaps you mean to refer directly to the element so it should be:
jQuery('#NewsPostedDate').datetimepicker({ format: 'DD/MM/YYYY' });
Note the # instead of the .
Upvotes: 1