Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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
STAFF
James Churchill
Treehouse Teacher

Jean,

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>
<script>
    $('input.datepicker').datepicker({
        format: 'd/m/yyyy',
        language: 'es-CO'
    });
</script>

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