calendar control in different languages?

N

nacho

It it possible to display the calendar control in
different languages according to the navigator culture?
If so, how (any www reference will be very appreciated)

Thanks.
 
K

Ken Cox [Microsoft MVP]

The code below tries to sniff the language. It also fills a dropdownlist with
the available languages on the system to investigate. You can see how talented
the calendar control is at languages.

Does this help?

Ken
MVP [ASP.NET]


Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim userLang() As String
Dim strName As String
userLang = Request.UserLanguages

If Not IsPostBack Then
Session("strLanguage") = userLang(userLang.GetUpperBound(0))
If Session("strLanguage") = "" Then
Session("strLanguage") = "en-US"
End If
Dim ci As CultureInfo
For Each ci In _
CultureInfo.GetCultures(CultureTypes.AllCultures)
If Not ci.IsNeutralCulture Then
ddlCultures.Items.Add(ci.ToString)
End If
Next ci
Dim dtNow As Date = DateTime.Now
strName = Session("strLanguage")
Thread.CurrentThread.CurrentUICulture = _
New CultureInfo(strName, False)
Thread.CurrentThread.CurrentCulture = _
New CultureInfo(strName)
Calendar1.SelectedDate = dtNow
Calendar1.VisibleDate = dtNow
End If
End Sub
Private Sub Calendar1_SelectionChanged _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Calendar1.SelectionChanged
Dim strName As String = Session("strLanguage")
Thread.CurrentThread.CurrentUICulture = _
New CultureInfo(strName, False)
Thread.CurrentThread.CurrentCulture = _
New CultureInfo(strName)
End Sub

Private Sub btnTry_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btnTry.Click
Dim strName As String
strName = ddlCultures.SelectedItem.Text
Session("strLanguage") = strName
Thread.CurrentThread.CurrentUICulture = _
New CultureInfo(strName, False)
Thread.CurrentThread.CurrentCulture = _
New CultureInfo(strName)
End Sub



<%@ Page Language="vb" AutoEventWireup="false" Codebehind="callocal.aspx.vb"
Inherits="p733workev.callocal"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>callocal</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body ms_positioning="FlowLayout">
<form id="Form1" method="post" runat="server">
<p>
<asp:dropdownlist id="ddlCultures"
runat="server"></asp:dropdownlist></p>
<p>
<asp:button id="btnTry" runat="server" text="Try It!"></asp:button></p>
<asp:calendar id="Calendar1" runat="server"></asp:calendar>
<p>&nbsp;</p>
<p>&nbsp;</p>
</form>
</body>
</html>


--

Important: Patch Windows *beyond* Blaster.
http://www.microsoft.com/technet/security/bulletin/MS03-039.asp


It it possible to display the calendar control in
different languages according to the navigator culture?
If so, how (any www reference will be very appreciated)

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
474,077
Messages
2,570,567
Members
47,204
Latest member
abhinav72673

Latest Threads

Top