Adding cultures to Kendo UI Project

By | February 14, 2014

You might have encountered an issue where your application is triggering a validation on a date field which says “The field YourDate must be a date.” like the image below.

00 Client Error

Or in server side after by passing the client it throws and exception “SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.” like the image below

00 Error

and after checking you parameters you found out that its not giving you the correct date you entered

00 Error 1

then most probably you are in country that is not using the American Date format and you are not using Kendo Globalization.  To verify that go to your scripts folder on your Web project and see if there is a cultures folder inside kendo -> the version you are using,  if there’s none then that is your problem.

To fix that is to simply import the cultures JS library on your Kendo UI installation path which by default is located in C:Program Files (x86)TelerikKendo UI for ASP.NET MVC Q2 2013js.  First you need to copy the culture you need or if you need multiple ones just copy everything inside the Kendo version scripts folder like in the screenshot below.

01 Add Culture

it should now look like this

02 Added

Now the library is there all you need to do is reference it to your project.  For this demo we will use New Zealand Locale but you can use multiple if  you want, you just have to programatically load the culture you want.

So if you are using bundles it will look like this

bundles.Add(new ScriptBundle("~/bundles/demo").Include("~/scripts/kendo/2013.2.918/cultures/kendo.culture.en-NZ.min.js"));

03 In Bundle

if not then place it in your Shared Layout page which is by default at _Layout.cshtml and it should look like this

<script src="~/Scripts/kendo/2013.2.918/cultures/kendo.culture.en-NZ.min.js"></script>

04 In Layout

Then all you need now is to set the current culture in _Layout.cshtml then you’re all good to go.

<script type="text/javascript">

05 Set Culture


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.