How to localize a menu control in a masterpage

Last post 03-13-2007 5:50 AM by SteliosM. 8 replies.

Sort Posts:

  • How to localize a menu control in a masterpage

    03-12-2007, 11:41 AM
    • Loading...
    • SteliosM
    • Joined on 10-16-2004, 2:42 AM
    • Greece
    • Posts 26

    Hi all,

    I'm devoloping a web site that must have two languages.

    I'm using a master page for the layout and I have two menu controls on the master page that must be changed according to language selection.

    Is it possible to do it with a local resource file? 

    Can you pls advice a method for this?

    I show the video in tutorials but I think that this must be a different approach.

    Thanks.

  • Re: How to localize a menu control in a masterpage

    03-12-2007, 1:04 PM
    Answer
    if you localize controls in the masterpage I would advice that you place your resource files in the global_resources folder, a file could be named: glossary.en.resx and glossary.fr.resx (for english and french respectively)
    then in you masterpage on the properties of the login control you can define the text on the controls in the login control, e.g. Logintext="<%$Resources:Glossary, Logintext"

    HTH
    please mark answers as 'Answered' and post back solutions when you figure stuff out.

    join www.floxtar.com: the first community where YOU help make a difference! Support a good cause and it doesnt cost you a thing!
  • Re: How to localize a menu control in a masterpage

    03-12-2007, 7:06 PM
    • Loading...
    • SteliosM
    • Joined on 10-16-2004, 2:42 AM
    • Greece
    • Posts 26

    Thank you (HTH?)

    I tried your way it is working fine. But there is another problem rising. I have to click the language button twice to have the page reflect the language change. Or if I click one time the button and then refresh the browser will show me the selected language. WHY?

    When the client click one of the language buttons,I set a session variable to the selected language.

    The language buttons reside on the master page.

    In the content page I added the following code:

    Imports

    System.Threading

    Imports

    System.Globalization

    Partial

    Class _Default

    Inherits System.Web.UI.Page

    Protected Overrides Sub InitializeCulture()

    Dim lang As String = Session("LangSelected")

    If lang IsNot Nothing Or lang <> "" Then

    Thread.CurrentThread.CurrentUICulture =

    New CultureInfo(lang)

    Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(lang)

    End If

    End Sub

    End

    Class

    Can you please advice about this?

     Thanks

  • Re: How to localize a menu control in a masterpage

    03-12-2007, 7:42 PM

    HTH=hope that helps :)

    first
    over here:
    If lang IsNot Nothing Or lang <> "" Then
    I think you mean AND instead of Or?

    also, why wouldnt you pass the current language in the querystring? that way you enable users also to bookmark your site in the language they prefer...

    the code in your InitializeCulture method looks fine to me.
    did you step into your code and checked the actual value of the "LangSelected" variable?

    does it get updated correctly?

    please mark answers as 'Answered' and post back solutions when you figure stuff out.

    join www.floxtar.com: the first community where YOU help make a difference! Support a good cause and it doesnt cost you a thing!
  • Re: How to localize a menu control in a masterpage

    03-12-2007, 8:25 PM
    • Loading...
    • SteliosM
    • Joined on 10-16-2004, 2:42 AM
    • Greece
    • Posts 26

    Oops! I didn't knew it. :(

    Yes I checked the session variable and it gets the values. I thing that there is not a really postback. When I refresh the browser the new string values comes up.

    I read about some basefile in app_folder but I think it is very complicated. The solution must be simple...

    Any ideas?

  • Re: How to localize a menu control in a masterpage

    03-13-2007, 5:04 AM
    on which event do you set the selected language?
    Is is a dropdownlist? check if the autopostback property of your control is set to true..

    Otherwise could you post your code?
    please mark answers as 'Answered' and post back solutions when you figure stuff out.

    join www.floxtar.com: the first community where YOU help make a difference! Support a good cause and it doesnt cost you a thing!
  • Re: How to localize a menu control in a masterpage

    03-13-2007, 5:39 AM
    • Loading...
    • SteliosM
    • Joined on 10-16-2004, 2:42 AM
    • Greece
    • Posts 26

    I was using a dropdwnlist with the autopostback enabled but I felt.

    Now, I changed the dropdownlist with two image buttons and I have the same effect.

    Fisrt I had only:

    Session("LangSelected") = "en-us"

    in the click event of the image button and  

    I had to add to the following to make it work.

    Response.Redirect(Page.AppRelativeVirtualPath,

    True)

    Now it is working fine.

    Thank you for your help.

    I need some other info if you pleased.

    I have some code in the content page that overrides the InitializeCulture. Is it possible to have it in a separate file in app_code and have all pages inherit the code from there?

  • Re: How to localize a menu control in a masterpage

    03-13-2007, 5:46 AM
    Just a tip, if you ask a new question, you should start a new thread, that way other people can also keep learning from your experiences.

    I dont know exactly what you are trying to achieve, so could you explain a bit further?
    please mark answers as 'Answered' and post back solutions when you figure stuff out.

    join www.floxtar.com: the first community where YOU help make a difference! Support a good cause and it doesnt cost you a thing!
  • Re: How to localize a menu control in a masterpage

    03-13-2007, 5:50 AM
    • Loading...
    • SteliosM
    • Joined on 10-16-2004, 2:42 AM
    • Greece
    • Posts 26

    Ok Peter. I will post it in a new post. This is a good suggestion.

    Thanks again.

Page 1 of 1 (9 items)
Microsoft Communities
Page view counter