I need to change date format to be dd.MM.yyyy
. I am getting client side validation error because ASP.NET MVC date format is different from what I expect on the
As a potential aid for identifying the issue, are you able to: 1. Set a breakpoint at the point where you're trying to format the date 2. Use something like the Immediate Window in Visual Studio to evaluate the value of
Thread.CurrentThread.CurrentCulture.Name
If you do this, does it come back with the "ru-RU" culture?
I'm sure I'm not the only one that would be happy to help you work through debugging this. That said, perhaps somebody quicker than me can see the problem straight away :).
Edit: It looks like you're using Razor, so you should be able to set a breakpoint directly in the view file on the line where you're trying to format the date.
Edit #2:
There may be a cleaner way to do this, but if the form data is being posted in dd.MM.yyyy then you might need a custom model binder, something like:
public class CustomModelBinder : DefaultModelBinder
{
public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
// custom bind the posted date
}
}
...which would then get assigned as a model binder in e.g. ApplicationStart in Global.asax.cs.
Let me know if you think this might help and I can elaborate.