I am currently developping a web application using ASP.NET MVC 4. Here is a description of the problem I am facing :
I created a strongly-typed view in order to edit some fields of a table, and in particular a DateTime
field. What I want to do is to display a textbox with the default value retrieved from the database using the following code :
@Html.TextBoxFor(m => m.Date, new { @Value = ViewBag.DefaultValue })
where ViewBag.DefaultValue
is set in the Controller using a simple query. Since I am talking about dates, I also have added this in my web.config :
<globalization uiCulture="fr-Fr" culture="fr-FR" />
Now the fun part is that, when displayed, the date has a MM/DD/YYYY format instead of a DD/MM/YYYY one, which is the one saved in the database. Moreover, when I just want to display the ViewBag.DefaultValue
in a div, it shows the correct format, ie DD/MM/YYYY.
Has anyone faced some similar issues? I can understand that my description can be rather vague, but I really don't understand what is going on there.
Thanks in advance.