Thursday, June 17, 2010
Is it possible to change RadDatePicker language?
Yes, It is possible. We just need to put this line of code in the Page_Load event.
1 radDateFrom.Calendar.CultureInfo = New System.Globalization.CultureInfo(strLang)
radDateFrom = your radDatePicker control.
strLang = Your Selected Language
See a Complete small example
The Client code:
1 <form id="form1" runat="server">
2 <asp:ScriptManager ID="ScriptManager1" runat="server" />
3 <div>
4 <asp:DropDownList ID="ddl1" runat="server" AutoPostBack="True">
5 <asp:ListItem Text="en-US" />
6 <asp:ListItem Text="bg-BG" />
7 <asp:ListItem Text="es-ES" />
8 </asp:DropDownList>
9 <telerik:RadDateTimePicker ID="RadDateTimePicker1" runat="server" meta:resourcekey="RadDateTimePicker1Resource1">
10 <Calendar AutoPostBack="false" RangeMinDate="01/01/2009" RangeMaxDate="12/12/2009"
11 EnableViewSelector="true" MultiViewColumns="2" MultiViewRows="2" EnableNavigation="true"
12 meta:resourcekey="RadCalendar1Resource1" />
13 </telerik:RadDateTimePicker>
14 </div>
15 </form>
The code behind:
1 Partial Class Pages_RadExample
2 Inherits System.Web.UI.Page
3
4
5 Protected Overrides Sub InitializeCulture()
6 Dim selectedLanguage As String = "en-US"
7 If Request.Form("ddl1") IsNot Nothing Then
8 selectedLanguage = Request.Form("ddl1")
9 End If
10 System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo(selectedLanguage)
11 System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo(selectedLanguage)
12 MyBase.InitializeCulture()
13 End Sub
14
15 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
16 Dim selectedLanguage As String = "en-US"
17 If Request.Form("ddl1") IsNot Nothing Then
18 selectedLanguage = Request.Form("ddl1")
19 End If
20 RadDateTimePicker1.Calendar.CultureInfo = New System.Globalization.CultureInfo(selectedLanguage)
21 End Sub
22 End Class
Subscribe to:
Post Comments (Atom)
Very useful!
ReplyDelete