Date is empty in view textboxfor when adding type "date"

Viewed 3016

Weird problem that is probably very obvious. In my view model I have a date, which I set in the controller. When I render the textbox in the view, it is empty.

View model:

   [DataType(DataType.Date)]
   [DisplayFormat(DataFormatString = "{0:dd-MM-yyyy}")]
   public DateTime DateStart { get; set; }

Controller:

    //GET: InvoicePrice
    public ActionResult Index(InvoicePriceViewModel model)
    {
        model.DateStart = DateTime.Now;
        return View(model);
    }

HTML of view:

    <p>
      Date:<br />
            @Html.TextBoxFor(model => model.DateStart, new { @class = "form-control", placeholder = "Invoice date", type = "date" })
     </p>

When I open this, I get the empty textbox here:

enter image description here

And I would expect to see "28-11-2017" as my current date.

I guess I am missing something obvious here. But what is it?

2 Answers
Related