Hello,
I can't get formatted DateTime in MVC 5 Edit-Modus.
(In Show-Modus it works OK)
What I'm doing wrong?
My Model as follow:
namespace WebApplication3.Models
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
public partial class KEYWORD
{
[DisplayFormat(ApplyFormatInEditMode=true, DataFormatString = "{0:dd.MM.yyyy}", ConvertEmptyStringToNull = true, HtmlEncode = true, NullDisplayText ="" ) ]
public Nullable<System.DateTime> DATE_NEW { get; set; }
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd.MM.yyyy}", ConvertEmptyStringToNull = true, HtmlEncode = true, NullDisplayText = "")]
public Nullable<System.DateTime> DATE_EDIT { get; set; }
My Edit.chtml
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>KEYWORD</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.DATE_NEW, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.DATE_NEW, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.DATE_NEW, "", new { @class = "text-danger" })
</div>
</div>
Make IT better.