Question

My application has culture set to en-US and UI Culture set to nl-NL.

In my model I have a DateTime field. In my view if I fill in the Datetime field with a date in the Dutch format like 29-01-2014 than the mode binder does not pick it up because it does not consider the UI Culture.

How can I tell the mode binder to consider the UI culter when binding the dates or floats numbers from the form to the model.

Was it helpful?

Solution

How can I tell the mode binder to consider the UI culter when binding the dates or floats numbers from the form to the model.

You can't. You will need to write a custom model binder if you want to achieve that. I have illustrated how such a custom model binder might look like here: https://stackoverflow.com/a/7836093/29407. In this example the model binder is using a format specified in the DisplayFormat attribute when parsing the DateTime value, but you could trivially easy adapt it to use the current UI culture format instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top