public class BasePage : System.Web.UI.Page { public const string LanguageDropDownID = "ctl00$ddlLanguage"; public const string PostBackEventTarget = "__EVENTTARGET"; public static CultureInfo Culture; public static DateTimeStyles Style; public BasePage() { if (DateTime.Now < DateTime.Parse("01-Jan-14 11:59:59 PM") && DateTime.Now > DateTime.Parse("01-Jan-01 12:00:00 AM")) { Culture = CultureInfo.CreateSpecificCulture("en-GB"); Style = DateTimeStyles.None; } else throw new Exception("Your Licence Period is expire please Submited your due payment & Conntinue your Services !"); // Culture = CultureInfo.CreateSpecificCulture("en-GB"); //Style = DateTimeStyles.None; } protected override void InitializeCulture() { ///<remarks><REMARKS> ///Check if PostBack occured. Cannot use IsPostBack in this method ///as this property is not set yet. ///</remarks> if (Request[PostBackEventTarget] != null) { string controlID = Request[PostBackEventTarget]; if (controlID.Equals(LanguageDropDownID) || controlID.Equals("ddlLanguage")) { Session["LanguageChanged"] = true; string selectedValue = Request.Form[Request[PostBackEventTarget]].ToString(); switch (selectedValue) { case "1": SetCulture("en-GB", "en-GB"); break; case "2": SetCulture("hi-IN", "hi-IN"); break; default: break; } } else Session["LanguageChanged"] = false; } else if (Session["MyUICulture"] == null) { SetCulture("hi-IN", "hi-IN"); Session["LanguageChanged"] = false; } else SetCulture(Session["MyUICulture"].ToString(), Session["MyUICulture"].ToString()); ///<remarks> ///Get the culture from the session if the control is tranferred to a ///new page in the same application. ///</remarks> if (Session["MyUICulture"] != null && Session["MyCulture"] != null) { Thread.CurrentThread.CurrentUICulture = (CultureInfo)Session["MyUICulture"]; Thread.CurrentThread.CurrentCulture = (CultureInfo)Session["MyCulture"]; } base.InitializeCulture(); } protected void SetCulture(string name, string locale) { Thread.CurrentThread.CurrentUICulture = new CultureInfo(name); Thread.CurrentThread.CurrentCulture = new CultureInfo(locale); ///<remarks> ///Saving the current thread's culture set by the User in the Session ///so that it can be used across the pages in the current application. ///</remarks> Session["MyUICulture"] = Thread.CurrentThread.CurrentUICulture; Session["MyCulture"] = Thread.CurrentThread.CurrentCulture; } protected void Page_PreInit(Object sender, EventArgs e) { if (Session["MyUICulture"] != null) { if (Session["MyCulture"].ToString() == "hi-IN") this.Page.Theme = "Hindi"; else this.Page.Theme = "English"; } else this.Page.Theme = "Hindi"; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)