I'm trying to make an EditorForwhere it's value will be today's date, but I can't seem to figure out why it's not working.
I've tried a couple things already, but none of them seem to work.
Attempt 1:
View:
@Html.EditorFor(model => model.Opgevoerd, new { htmlAttributes = new { @class = "form-control", type = "DateTime", placeholder = "dd/mm/yyyy", value=DateTime.Now } }) Attempt 2:
Controller:
Model.Opgevoerd = DateTime.Now; return View(Computers___tabel); View:
@Html.EditorFor(model => model.Opgevoerd,"{0:dd/mm/yyyy}", new { htmlAttributes = new { @class = "form-control", type = "DateTime", placeholder = "dd/mm/yyyy" } }) I don't remember attempt 3 x)
I've been stuck at this for quite a while and I can't seem to figure it out.
Thanks!
value=DateTime.NowtoValue=DateTime.NowHtmlHelpermethods bind to your model. Set the value ofOpgevoerdin the GET method and return the model to the view. -model.Opgevoerd = DateTime.Now; return View(model);Do NOT attempt to set thevalueattribute.