-1

I am working on a c# mvc project. In one of my Index views i have a column called "Last Cut Off Date" for date, its value is: 28/07/2016. When i go to the Edit view of that row, i have a form and one of its fields is "Last Cut Off Date" (it is a datepicker field). When i run my project on Internet Explorer the date is preselected with value: 2016-07-28 and when i run my project on Google Chrome, the date is preselected with value: 07/28/2016. I need the preselected value to be in format: dd/MM/yyyy. How can i achieve this on both Google Chrome and Internet Explorer?

Here is the code from the Model:

    [DataType(DataType.Date)]
    [DisplayFormat(DataFormatString="{0:yyyy-MM-dd}",ApplyFormatInEditMode = true)]
    public Nullable<DateTime> LastCutoffDate { get; set; }
Ahmed
  • 1,542
  • 2
  • 13
  • 21
ppetyr
  • 111
  • 1
  • 10
  • show us the html ( View razor code) – Emil Nov 10 '16 at 15:57
  • @Html.EditorFor(model => model.LastCutoffDate, new { htmlAttributes = new { @id = "LastCutoffDate" } }) – ppetyr Nov 10 '16 at 16:00
  • try this http://stackoverflow.com/questions/18275009/asp-net-mvc-c-sharp-chrome-not-showing-date-in-edit-mode – Emil Nov 10 '16 at 16:07
  • As stated in your [previous question](http://stackoverflow.com/questions/40509967/preselected-value-of-date-picker-not-shown-in-google-chrome) you have no control over the browser –  Nov 10 '16 at 21:54

1 Answers1

0

In your view you can set the output for how the model will be displayed.

@Html.EditorFor(model => model.LastCutoffDate, "{0:dd/MM/yyyy}", new {  @class = "form-control" })
Andy Donegan
  • 782
  • 1
  • 9
  • 30