Calendar web control and different languages

A

Adrian Parker

I have a calendar control that I use as a popup on web pages.

When a browser session comes in with a different language e.g. French, the date.tostring(sFormat,oCultureInfo) function will convert
the names of the months / days etc to french. However, the calendar control always displays the months / days in English. How do
I force the calendar control to use the specific cultures names ?
 
P

Peter Huang

Hi Adrian,

From the description, it seems that you wants the set the CultureInfo of
Calendar Webcontrol.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

I think you may try to set the current thread's culture in the OnInit
method.

override protected void OnInit(EventArgs e)
{

System.Threading.Thread.CurrentThread.CurrentCulture =new
System.Globalization.CultureInfo("fr-FR");
InitializeComponent();
base.OnInit(e);
}

Here is the link about predefined CultureInfo names and identifiers are
accepted and used by CultureInfo Class

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemglobalizationcultureinfoclasstopic.asp

Please apply my suggestion above and let me know if it helps resolve your
problem.


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

Adrian Parker

Thanks Peter.

It worked, but I don't see why I have to do that in the specific page when I have

Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.UserLanguages(0))

in the session start event.

-Adrian
 
P

Peter Huang

Hi Adrian,

If you wants to persist the culture information during the whole session of
certain user, you can do the things in the Global.asax file.

protected void Session_Start(Object sender, EventArgs e)
{
HttpContext.Current.Response.Cookies.Add(new HttpCookie("cul","fr-FR"));
System.Threading.Thread.CurrentThread.CurrentCulture=new
System.Globalization.CultureInfo("fr-FR");
}

protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{
if (HttpContext.Current.Request.Cookies["cul"]!=null )
{
System.Threading.Thread.CurrentThread.CurrentCulture=new
System.Globalization.CultureInfo(HttpContext.Current.Request.Cookies["cul"].
Value.ToString());

}
}

In this way, when you redirect the page another one, the culture will not
change.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

Top