Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

C# ASP.NET MVC Forms Finishing Our CRUD Web App Creating a Partial View for Our Form

Proj Culture Config

The problem is when the app send "POST" to server the ModelState Is not valid cause the "Date" field isn't passing validation the error message is the next ("The value '4/26/2016' is not valid for Date."). In debug mode i can see that the culture config is set to my local config {es-CO} If i'm right, there is some way to set the project culture config? What's the correct way to avoid this kind of problems, given the country where i'm living ?

I already solved ! In the web.config: <system.web> <globalization culture="en-US" uiCulture="en-US"/> </system.web>

1 Answer

James Churchill
James Churchill
Treehouse Teacher


Great job finding a workaround to the problem!

Ideally, the Fitness Frog app would properly handle languages that use the date format of "d/m/yyyy". As it turns out, the datepicker that is used in the course does in fact support this.

<script src="~/Scripts/bootstrap-datepicker.min.js"></script>
<script src="~/Scripts/bootstrap-datepicker.es.min.js"></script>
        format: 'd/m/yyyy',
        language: 'es-CO'

Notice that I added an additional script include for the "bootstrap-datepicker.es.min.js" file. Doing this allows the calendar to be displayed with the correct names. Then, I had to update the datepicker configuration to use the correct format and language.

More information about the bootstrap-datepicker's support for I18N can be found here: https://bootstrap-datepicker.readthedocs.io/en/latest/i18n.html

You can see a list of the supported locales here: https://github.com/uxsolutions/bootstrap-datepicker/tree/master/dist/locales

To be clear, hard-coding the datepicker configuration values is the problem. What we should be doing is using the culture information that ASP.NET provides to us to determine what the datepicker format and language should be. I think that's a great idea for workshop!

Thanks ~James