0

我的网站使用 VS 2010 / vb 本地化为 10 种语言。当我首先单击该标志时,它会更改为该语言。但是当我单击另一种语言时,它不会切换;我必须再次单击它才能切换。有谁知道我的问题是什么?

这是我的 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

这是我的 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

任何建议或指导将不胜感激!

4

1 回答 1

1

这可能与 ASP.net 的生命周期有关。当您单击链接按钮时,页面会在执行 RequestLanguageChange_Click 事件之前重新加载。这意味着您的页面是在会话变量更改之前加载的。但是,由于您执行了 server.transfer,因此应该没有问题(双刷新除外)。我不太了解生命周期,但您应该检查一下,也许它会对您有所帮助。

于 2012-04-25T17:57:04.407 回答