locked
Changing language using buttons instead of drop down list RRS feed

  • Question

  • User1456393972 posted

    I can change the language of my site using a drop down list put I cant do it with buttons.

     

    I have a button for each language.  The user clicks on a button to choose their language.

    The problem is that the "button click" code happens after the "Initialize Culture" Code.

    So the language only changes after a page refresh.

    I don't want to use parameters e.i. www.mysite.com/?param=en

    I want to change the language through code.

     

    If someone can solve this for me, I'll be real happy.

     

    P.S. I'm using C#

     

     

    Friday, December 3, 2010 10:32 AM

Answers

  • User-821857111 posted

    Check the value of each button in the Initialize culture code to see if one was clicked.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, December 4, 2010 4:07 AM
  • User-519136805 posted

    Use Session variable, which can identify - In which culture the site is running.

    So when u press button , in that click event of button change the session variable to that culture & based on Culture Session variable , you can set your culture using basepage or page init event..

    Hope this will help !!!


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 8, 2010 1:34 AM

All replies

  • User-821857111 posted

    Check the value of each button in the Initialize culture code to see if one was clicked.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, December 4, 2010 4:07 AM
  • User-519136805 posted

    Use Session variable, which can identify - In which culture the site is running.

    So when u press button , in that click event of button change the session variable to that culture & based on Culture Session variable , you can set your culture using basepage or page init event..

    Hope this will help !!!


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 8, 2010 1:34 AM
  • User1456393972 posted

    All those worked.  Thanks.

    Friday, January 14, 2011 12:15 PM
  • User1456393972 posted

    NOTE:

    Ive come back to this thread to give one important feedback on what I've learned since I made multiligual sites.

    If you want search engines to index all language versions of your site, you need to use the query string method.

    If not, search engines will NOT index all languages on your site. 

    This is because search engines will only index an url once.  So if a page is in french and english and both share the same url, withought a query string, you will only be able to index one version of that page.

    With a query string, it is seen as a different page because it has a different url.

    I put my french version with a lang=fr query string and put no query sting on english.  This makes english my default language.  All other languages have a query string.

    If there is no query string, show the default language, if not, choose the language according to the "lang" query.

    This solved my problem bieautifully.  All my pages are now indexed.

    Thursday, September 1, 2011 5:57 PM