My website is localized in 10 languages, using VS 2010 / vb. When I click the flag first, it changes to that language. But when I click a separate language, it doesn't switch; I have to click it another time for it to switch. Does anyone know what my problem is?
Here's my code behind for my homepage.master.vb:
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports Udev.MasterPageWithLocalization.Classes
Partial Public Class Homepage
Inherits System.Web.UI.MasterPage
Protected Sub Page_Load(sender As Object, e As EventArgs)
End Sub
Protected Sub RequestLanguageChange_Click(sender As Object, e As EventArgs)
Dim senderLink As LinkButton = TryCast(sender, LinkButton)
'store requested language as new culture in the session
Session(Udev.MasterPageWithLocalization.Classes.Global.SESSION_KEY_CULTURE) =
senderLink.CommandArgument()
'reload last requested page with new culture
Server.Transfer(Request.Path)
End Sub
End Class
Here is my code behind for my default.aspx.vb:
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports Udev.MasterPageWithLocalization.Classes
Partial Public Class _Default
Inherits BasePage
Protected Sub Page_Load(sender As Object, e As EventArgs)
End Sub
End Class
Any suggestions or guidance would be greatly appreciated!
This probably have something to do with the life cycle of ASP.net. When you click on your linkbutton, the page reload before executing the RequestLanguageChange_Click event. This means your page is loaded before the session variable is changed. However, since you do a server.transfer, it shouldn't be a problem (except for the double refresh). I don't a lot about lifecycle but you should check it out, maybe it'll help you.