Localize one control only

Discussion in 'ASP .Net' started by MattB, May 9, 2005.

  1. MattB

    MattB Guest

    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
    MattB, May 9, 2005
    #1
    1. Advertising

  2. MattB

    Karl Seguin Guest

    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

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
    http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
    come!)


    "MattB" <> wrote in message
    news:...
    >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
    Karl Seguin, May 10, 2005
    #2
    1. Advertising

  3. MattB

    MattB Guest

    Karl Seguin wrote:
    > 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
    MattB, May 10, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Goofy

    Localize control Vs Literal

    Goofy, Dec 14, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    710
    Goofy
    Dec 14, 2006
  2. Arti
    Replies:
    0
    Views:
    408
  3. Johndoe

    Localize control

    Johndoe, Dec 28, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    314
    Teemu Keiski
    Jan 1, 2006
  4. Julia

    how to localize a composite control

    Julia, Jun 26, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    171
    Vadivel Kumar
    Jun 26, 2006
  5. Replies:
    0
    Views:
    307
Loading...

Share This Page