locked
Localization and globalization problem ...please help ... RRS feed

  • Question

  • User1664382952 posted

    Hello all,
    I made this project and I had a problem I didn't know where it is..
    The project has already asked for help here in this site....
    But the problem now is that the return value of the web.config
    Gives null
    ... I mean that the value of ddlLanguage still null when I debug the program
    but the value of the appsetting appears in the ddlLanguage
    but when I asked to used it through my work gave me that is null ...
    what is the expected problem here ?

    this is the master page
    Site.Master.cs :
     public partial class Site : System.Web.UI.MasterPage
        {

            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    string ddlstr = ConfigurationManager.AppSettings["Language"];
                    var list = ddlstr.Split(',');
                    for (int i = 0; i < list.Count(); i++)
                    {
                        var list01 = list[i].Split(':');
                        ListItem item = new ListItem(list01[1], list01[0]);
                        this.ddlLanguage.Items.Add(item);
                    }
                    this.ddlLanguage.SelectedValue = "en-US";
                    
                }
            }

            protected void ddlLanguage_SelectedIndexChanged(object sender, EventArgs e)
            {
                HttpCookie cookie = new HttpCookie("language", ddlLanguage.SelectedValue);
                Response.Cookies.Add(cookie);

            }
           
        }

    this is the LoginPage.aspx.cs  which used Master Page :
     public partial class LoginPage : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
         
            }
            protected override void InitializeCulture()
            {
                if(Request.Form["ddlLanguage"]!=null)
                {
                    String selectedLanguage = Request.Form["ddlLanguage"];
                    UICulture = selectedLanguage;
                    Culture = selectedLanguage;
                    Thread.CurrentThread.CurrentCulture =
                        CultureInfo.CreateSpecificCulture(selectedLanguage);
                    Thread.CurrentThread.CurrentUICulture = new
                        CultureInfo(selectedLanguage);
                }
                base.InitializeCulture();
            }
        }
    }

    ( I have Resources File for arabic,English and Espanish )
    and I did this in web.config
      <appSettings>
        <add key="Language" value="ar:Arabic,en-US:English,es:espanish"/>
      </appSettings>

    what is the problem here ? please help me :(

    thank you ....

    Sunday, May 31, 2015 7:58 AM

All replies

  • User2119946224 posted

    Same code i tried and it is working for me. I got dropdown values and all.

    Regards,

    Tuesday, June 20, 2017 5:14 AM