Click here to Skip to main content
15,911,762 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there no support for hi-IN (Hindi-India) culture in ASP.Net ???
When I move on Internet Explorer 8,9

it is ok with IE7....I am new Please give your view how to use culture for all browser compatibility ...
i used in my base page this code....



C#
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Globalization;
using System.Threading;

/// <summary>
/// Summary description for BasePage
/// </summary>
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()
    {
        //
        // TODO: Add constructor logic here
        //
        /*if (DateTime.Now < DateTime.Parse("03/31/2014") && DateTime.Now > DateTime.Parse("01/01/2010"))
        {
            Culture = CultureInfo.CreateSpecificCulture("en-GB");
            Style = DateTimeStyles.None;

        }
        else
            throw new Exception("Server is Responding Please Contact to Server Operater");*/
    }
   protected override void InitializeCulture()
    {
        /////////<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["LanguageChange"] = 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.


            if(Session["MyUiCulture"] !=null && Session["MyUICulture"]!=null)
            {
                Thread.CurrentThread.CurrentUICulture=(CultureInfo)Session["MyUICulture"];
                Thread.CurrentThread.CurrentCulture=(CultureInfo)Session["MyCulture"];
            }
        base.InitializeCulture();
    }



    /// Sets the current UICulture and CurrentCulture based on the arguments

    protected void SetCulture(string name, string local)
    {
        Thread.CurrentThread.CurrentUICulture = new CultureInfo(name);
        Thread.CurrentThread.CurrentCulture = new CultureInfo(local);
        ///<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.

        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="English";

    }
}
Posted

1 solution

you need to set Page.UICulture as "in" and then create a resource page at local resouce like this:
default.aspx.in.resx
 
Share this answer
 
Comments
Faizymca 18-Apr-13 3:30am    
Sir, I used ChangeCultures.hi-IN.resx for hindi with theme (using font Kruti Dev 010 for label,textbox ddl etc) and ChangeCultures.resx for english . Sir Problem Hindi Culture not Working in IE9 how can i removed this problems...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900