1

I have develop an MVC C# application, published in Somee.

Only in Somee I have a problem with datetime format (US vs IT)

I have a typed list view whit, for each row, a date field and same record edited in a partial view.

Data Annotation class:

[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
public DateTime DataCons { get; set; }

In list view I used:

<td>@Html.EditorFor(Model => Model[c].DataCons, "{0:dd/MM/yyyy}", new { @style = "width: 140px;" })</td>

and a calendar is used and no problem with date time format

In partial view for editing record, same code used in list view doesn' t work and I need to use TextBoxFor instead EditorFor, a model binder to convert datetime format and a javascript date-picker.

 @Html.TextBoxFor(m => m.Scadenza, "{0:dd/MM/yyyy}", new { @class = "date-picker", style = "width: 90px;" })

A way to unify my code maybe setting somee language setting?

Regards

0 Answers0