I searched almost every topic on this site regarding date format also DatePicker however couldn't find any solution for my issue, also applied This with no success
Problems
- Date format is not applied in Partial views
- datepicker is not applied in Partial views
.cs
[DisplayFormat(DataFormatString = "{0:dd-MM-yyyy}", ApplyFormatInEditMode = true)]
public DateTime? RefDate{ get; set; }
Razor (Partial View)
In my main view, when Edit is clicked, i load a partial view inside a div, the partial view contains:
@Html.TextBoxFor(model => model.RefDate, new { @class = "form-control input-sm" })
DateTime.cshtml
@model DateTime?
@Html.TextBox("", (Model.HasValue ? Model.Value.ToString("dd/MM/yyyy") :string.Empty),
new { @class = "datepicker" ,@readonly = "readonly"})
Web.Config
<globalization culture='fr-BE' uiCulture='fr-BE' />
Result
02/18/2015 0:00:00
IF i use
@Html.EditorFor(model => model.RefDate, new { @class = "form-control input-sm" })
Result I don't see any value but this text:
mm/dd/yyyy
Also bootstsrap format is gone.