8 Apr 2011

Localization of jQuery UI DatePicker with ASP.NET

Hello folks! Do you want to make your jQuery DatePicker play nicely with your ASP.NET localization settings?

When you set up your DatePicker inputs on the page, try this:


$('.DatePicker').datepicker({
dayNamesMin: ['<%= string.Join("', '", System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortestDayNames) %>'],
monthNames: ['<%= string.Join("', '", System.Globalization.DateTimeFormatInfo.CurrentInfo.MonthNames) %>'],
monthNamesShort: ['<%= string.Join("', '", System.Globalization.DateTimeFormatInfo.CurrentInfo.AbbreviatedMonthNames) %>']
});

No comments:

Post a Comment

Comments are very welcome but are moderated to prevent spam.

If I helped you out today, you can buy me a beer below. Cheers!