Localize one control only

M

MattB

I need to make the stock asp calendar control appear in a different
language. Can this be done by changing properties of the calendar
control programmatically? I want to keep the rest of the application as
it is if possible. It needs to be in French. Thanks!

Matt
 
K

Karl Seguin

Matt, I enjoyed finding the solution to that question. The best way I could
think of was to use a custom control, ala:

ublic class LocalizedCalendar : Calendar
{
private string culture;

public string Culture
{
get { return culture; }
set { culture = value; }
}

protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
CultureInfo originalCulture =
System.Threading.Thread.CurrentThread.CurrentCulture;
if (culture != null && culture.Length > 0)
{
try
{
System.Threading.Thread.CurrentThread.CurrentCulture = new
CultureInfo(culture);
}
catch (ArgumentException ex){}

}
base.Render (writer);
System.Threading.Thread.CurrentThread.CurrentCulture = originalCulture;
}
}
}

Cheers,
Karl
 
M

MattB

Karl said:
Matt, I enjoyed finding the solution to that question. The best way I could
think of was to use a custom control, ala:

ublic class LocalizedCalendar : Calendar
{
private string culture;

public string Culture
{
get { return culture; }
set { culture = value; }
}

protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
CultureInfo originalCulture =
System.Threading.Thread.CurrentThread.CurrentCulture;
if (culture != null && culture.Length > 0)
{
try
{
System.Threading.Thread.CurrentThread.CurrentCulture = new
CultureInfo(culture);
}
catch (ArgumentException ex){}

}
base.Render (writer);
System.Threading.Thread.CurrentThread.CurrentCulture = originalCulture;
}
}
}

Cheers,
Karl

Wow. Thanks Carl! I'll start moving this to vb and give it a shot right
away!

Matt
 

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

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top