0

I am getting DateTime field on MVC page but it does not show on Page I am writing in the model,

[Display(Name = "Next Meeting")]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
[DataType(DataType.Date)]
public DateTime? NextMeeting { get; set; }

And on View,

<div class="form-group">
    @Html.LabelFor(model => model.NextMeeting, htmlAttributes: new { @class = "control-label col-md-4" })
    <div class="col-md-12">
        @Html.EditorFor(model => model.NextMeeting, new { htmlAttributes = new { @class = "form-control" } })
        @Html.ValidationMessageFor(model => model.NextMeeting, "", new { @class = "text-danger" })
    </div>
</div>

And When I was Run my MVC web page it shows a simple textbox field, This is a text field

How can I show DateTime field on the page?

kiran girase
  • 97
  • 2
  • 13
  • For a start it needs to be `DataFormatString = "{0:yyyy-MM-dd}"` (ISO format), but the HTML-5 datepicker is not supported an all browsers –  Apr 26 '18 at 06:54
  • thanks for the reply Stephen, it's correct the datepicker is not supported on Internet Explorer but I want to get. Thats why I am asking a question , what is the solution for that field to get DateTime picker? – kiran girase Apr 26 '18 at 07:22
  • Use a jquery plugin (for example [jQuery-ui datepicker](http://jqueryui.com/datepicker/)) –  Apr 26 '18 at 07:26
  • The jQuery datepicker is not working in MVC4 when I run the page, It shows an error – kiran girase Apr 26 '18 at 07:31
  • Then your code is wrong! –  Apr 26 '18 at 07:33

0 Answers0