Solved

Language change!

Posted on 2010-08-21
4
538 Views
Last Modified: 2012-06-27
Hi all,

I'm trying to get my application to detect what language the browser is set to, then make changes accordingly. So far I have:

Dim lang As String
lang = Request.QueryString("Language")
If lang = "it" then
Sidebar3.CssStyle = "sidebar h2"
End if

Open in new window


this didn't work, so I played around with trying 'language' instead of 'Language', and 'it-IT" instead of "it" but nothing seems to work.

Then I thought that maybe the string 'lang' wasn't working as it should, so I tried a

Response.Write(Request.QueryString("Language"))

Open in new window


nothing was written at all. As you can see in the first 'code' - I'm trying to change the CSS class of sidebar3 (an asp label) if the browser language is set to Italian. I've also tried doing a Select Case - this yields the same result, nothing.

I'm using IE8 and Chrome for testing, no variations on results for either.

Any help will be appreciated!

Jonathan
0
Comment
Question by:jonathangodwin
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:Navecha
ID: 33490913
hello,

have you looked into the folowing?

http://msdn.microsoft.com/en-us/library/system.web.httprequest.userlanguages.aspx

greets,

LN
0
 
LVL 1

Expert Comment

by:Navecha
ID: 33490917
(querystring is only for passing values with a [get]-form)

LN
0
 
LVL 1

Author Comment

by:jonathangodwin
ID: 33490962
Oh ok, so what would be the best way for me to achieve the objective in my original post? I tried:

Dim userLang() As String
        Dim count As Integer

        userLang = Request.UserLanguages
        For count = 0 To userLang.GetUpperBound(0)
            Response.Write("User Language: " & CStr(userLang(count)) & "<br>")
        Next count

which returns:

User Language: en-GB
User Language: it;q=0.8
User Language: en-US;q=0.6
User Language: en;q=0.4

but what can I do to isolate one of the above in an If statement?

Thanks,

Jonathan
0
 
LVL 1

Accepted Solution

by:
jonathangodwin earned 0 total points
ID: 33491025
Dim lang As String = Request.UserLanguages(0).ToString
if lang = "it" Then
SideBar3.CssClass = "<your css class goes here>"
End If

is how to do it for future reference for people
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

This is a how to build your own CSS3 slideshow and when I say CSS3 I mean just CSS with no javascript in sight! There a few examples online of how to do this but most just show you an example without any explanation, others make it more complicat…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now