I work in MVC c#. I want to modify the datetime display (Project contain some date).
In my class:
public ActionResult Edit(long id){
...
return View(project);
}
[HttpPost]
public ActionResult Edit(Project _project){
...
Save(_project);
return View();
}
In the EditorTemplate:
<%:Html.TextBox("", String.Format("{0:dd/MM/yyyy HH:mm}", Model.HasValue ? Model : DateTime.Today), new { @class = "dp" })%>
This version works well, bur when I try to modify the format to: {0:dd/MM/yyyy - HH:mm}, dates in _project are wrong (default value I think).
What does your
Projectmodel look like? Because in your ternary, you’re passing your model if itHasValue. I think that would be your problem.