changing Culturinfo on buttonclick

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,


I have this asp.net application in which the user can choose between three
possible languages. NL - FR - EN

How can I set the System.Globalization.CultureInfo to three different
values, just by clicking a button?
in a pageLoad i have something like this:
switch(vLang){
case "NL":
System.IFormatProvider format = new
System.Globalization.CultureInfo("nl-BE", true);
break;
case "FR":
System.IFormatProvider format = new
System.Globalization.CultureInfo("fr-BE", true);
break;
case "EN":
System.IFormatProvider format = new
System.Globalization.CultureInfo("en-Us", true);
break;
}
but I get errors

anyone a Clue ?
thx
 
that the variable 'format' is already known...
which in a switch - case construction seems illogic..
 
is the error happening IN the switch or when you try to use the "format"?
run it through the debugger and see where, specifically, it's bombing. Try
declaring "format" outside the switch, but assigning it within it.

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
 
You are defining it in every case. You should do it once before switch and
then just refer to it:

System.IFormatProvider format;
switch(vLang){
case "NL":
format = new
System.Globalization.CultureInfo("nl-BE", true);
break;
case "FR":
format = new
System.Globalization.CultureInfo("fr-BE", true);
break;
case "EN":
format = new
System.Globalization.CultureInfo("en-Us", true);
break;
}

Now, it makes sense to make a radio button list for the language selection
and to check wich option is selected in the switch statement.

Eliyahu
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top