문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top