0 Replies - 1817 Views - Last Post: 21 September 2012 - 12:32 AM Rate Topic: -----

#1 Nuha_IT  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 13-May 11

Calendar is not working from BaseClass

Posted 21 September 2012 - 12:32 AM

I had a problem with calendar in MasterPage so that's why I have used BaseClass, the problem was solved but the calendar stopped working.

My calendar has a listBox for choosing different georgian calendars, but whenevr I choose I doesn't work out.

This is my code for Base Class

 public class BasePage : System.Web.UI.Page
{
    Dictionary<string, System.Globalization.Calendar> Calendars =
        new Dictionary<string, System.Globalization.Calendar>()
        {
            {"GregorianCalendar", new GregorianCalendar()},
            {"HebrewCalendar", new HebrewCalendar()},
            {"HijriCalendar", new HijriCalendar()},
            {"JapaneseCalendar", new JapaneseCalendar()},
            {"JulianCalendar", new JulianCalendar()},
            {"KoreanCalendar", new KoreanCalendar()},
            {"TaiwanCalendar", new TaiwanCalendar()},
            {"ThaiBuddhistCalendar", new ThaiBuddhistCalendar ()}
        };

    protected override void InitializeCulture()
    {
        if (Request.Form["LocaleChoice"] != null)
        {
            string selected = Request.Form["LocaleChoice"];
            string[] calendarSetting = selected.Split('|');
            string selectedLanguage = calendarSetting[0];

            CultureInfo culture = CultureInfo.CreateSpecificCulture(selectedLanguage);

            if (calendarSetting.Length > 1)
            {
                string selectedCalendar = calendarSetting[1];
                var cal = culture.Calendar;
                if (Calendars.TryGetValue(selectedCalendar, out cal))
                    culture.DateTimeFormat.Calendar = cal;
            }

            Thread.CurrentThread.CurrentCulture = culture;
            Thread.CurrentThread.CurrentUICulture = culture;
        }
        base.InitializeCulture();
    }
}


What is the cause? Please Help.

Is This A Good Question/Topic? 0
  • +

Page 1 of 1