Muamar Jasim
Muamar Jasim

Reputation: 35

Bootstrap Date picker - ASP NET MVC Not excuted in my code

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

Answers (2)

Asif Raza
Asif Raza

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

Simon
Simon

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

Related Questions