Localize one control only

  • Thread starter Thread starter MattB
  • Start date Start date
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
 
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
 
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
 
Back
Top