4

My model

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

My view

@Html.EditorFor(m => m.TanggalLahir)

but its still display format data with MM/dd/yyyy.

even my web.config

<system.web>
  <globalization uiCulture="en" culture="en-GB"/>
  <authentication mode="None" />
  <compilation debug="true" targetFramework="4.5" />
  <httpRuntime targetFramework="4.5" maxRequestLength="30000000" />
</system.web>
koolprasad2003
  • 299
  • 3
  • 23
Onchomngebul
  • 63
  • 2
  • 8

4 Answers4

1

declare your property as string

[Display(Name = "Tanggal Lahir")]
[DataType(DataType.Date)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
public string TanggalLahir { get; set; }
Imad
  • 7,126
  • 12
  • 55
  • 112
0
@Html.EditorFor(m => m.TanggalLahir, "{0:dd/MM/yyyy}", new {maxlength = 10})

you can try something like that..

शेखर
  • 17,412
  • 13
  • 61
  • 117
Rizwan
  • 1
  • 1
0

1f you can't get it working on the model you could try it on the view.

 @Html.EditorFor(m => m.TanggalLahir, "{0:dd/MM/yyyy}", new {maxlength = 10})

(or)

  @Html.EditorFor(m => m.TanggalLahir, new { @Value = Model.StartDate.ToString("dd/MM/yyyy") })
Manraj
  • 496
  • 2
  • 15
0

Check out this, there are some useful info which might help you. Also make sure that you specify the CultureInfo as Invariant Culture.

Community
  • 1
  • 1
yala_cat
  • 309
  • 4
  • 21