I’m trying to create a querystring so when a user switches languages, the URL changes to ?lang=NL, for example. I have this in the code behind on homepage.master (VB, NOT C#):
Me.Request.QueryString("lang") <> Session([Global].SESSION_KEY_CULTURE) Then
Visual Studio underlines it in blue. When I hover over the left side of the statement, it says “Property Value Must Assign to the property or use its value” When I hover over the right side of the erred statement, it says, “End of Statement Expected”.
I’m not sure if the code I was given is C#, but when I use the Teleflex translator to check, it says “EOF Expected” and won’t translate.
All of this is tied into 3 classes I created, BasePage.vb, Culture.vb, and Global.vb. But I think it’s just this line that’s screwing everything up. If anybody knows the solution, I’d sincerely appreciate you sharing it with me, ’cause this is frustrating. Thanks!
p.s.: If necessary, here’s my entire homepage.master.vb:
Partial Public Class Homepage
Inherits System.Web.UI.MasterPage
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Init
If Session([Global].SESSION_KEY_CULTURE) Is Nothing OrElse _
Me.Request.QueryString("lang") <> Session([Global].SESSION_KEY_CULTURE) Then
RequestLanguageChange(Me.Request.QueryString("lang"))
End If
End Sub
Protected Sub RequestLanguageChange(ByVal culture As String)
'store requested language as new culture in the session
Session([Global].SESSION_KEY_CULTURE) = culture
'reload last requested page with new culture
Server.Transfer(Request.Path)
End Sub
Private Function [Global]() As Object
Throw New NotImplementedException
End Function
End Class
Have you tried putting the following two lines on a single line:
Like: