Try this;
@Html.TextBoxFor(model => model.CreationDate,
new { @type = "date", @Value = Model.CreationDate.ToString("yyyy-MM-dd") })
You have to handle null
when setting the value.
OR
If you can change the Model
you can try this;
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
public DateTime CreationDate{ get; set; }
and in your view you can use EditorFor
helper.
@Html.EditorFor(model => model.CreationDate, new { @type = "date" })