2
votes

Hi I Am Using Mvc With Kendo Ui So I want to change My Culture To en-GB So I Used this Link

http://docs.telerik.com/kendo-ui/aspnet-mvc/globalization

To change My Culture And that's Works Fine For

The Grid Not For Date time Picker

I Used Format Method And Parse Format and Still Does not Work

2
add some code for your controller, view and editor template - Monah

2 Answers

3
votes

try the following

1- your EditorTemplate date.cshtml

@model DateTime?

@(Html.Kendo()
      .DatePickerFor(m => m)      
      .HtmlAttributes(new { tabindex = ViewData["tabindex"] })
      .Format("dd MMM yyyy")
      .ParseFormats(new string[]{"yyyy-MM-dd"})
)

2- in your Global.asax

 protected void Application_BeginRequest(object sender, EventArgs e)
 {

     CultureInfo info = new CultureInfo("en-GB");
     info.DateTimeFormat.ShortDatePattern = "dd MMM yyyy";
     info.DateTimeFormat.LongDatePattern = "dd MMM yyyy HH:mm";
     info.NumberFormat.NumberDecimalDigits = 2;
     Thread.CurrentThread.CurrentCulture = info;
     Thread.CurrentThread.CurrentUICulture = info;
 }

3- in your _layout.cshtml

  <script>
        kendo.culture("en-GB");
        var culture = kendo.culture();
        culture.calendar.patterns.d = "dd MMM yyyy";
        culture.calendar.patterns.D = "dd MMM yyyy";
        culture.calendar.patterns.t = "HH:mm";
        culture.calendar.patterns.T = "HH:mm";
        culture.calendar.patterns.g = "dd MMM yyyy HH:mm";
        culture.calendar.patterns.G = "dd MMM yyyy HH:mm";
    </script>

5- make sure you added the javascript file for the culture required

hope this will help you

2
votes

If you are using Kendo API Reference in your ASP.NET Mvc. Refer below Code

Script:

$("#datepicker").kendoDatePicker({
    format: "yyyy/MM/dd", // Provide your custom format here
    culture: "en-GB" // Provide your current Culture
});

If it is Razor Tag or Server Tag.

Server Tag:

<%= Html.Kendo().DatePicker()
              .Name("monthpicker")
              .Format("MMMM yyyy")
              .Culture("en-GB")
              .Value("November 2011")%>

Razor Tag:

@(Html.Kendo().DatePicker()
      .Name("end")
      .Name("monthpicker")
      .Format("MMMM yyyy")
      .Culture("en-GB"))

Some reference:

Date Picker Culture

Date Picker Format

Kendo ASP.Net-MVC Datepicker