<asp:content id="ContentLogin" contentplaceholderid="Main_Content" runat="server">
<div> <asp:Label ID="Label1" runat="server" Text="Select Culture" meta:resourcekey="Selectculture">asp:Label> <asp:DropDownList ID="Language1" AutoPostBack="true" OnSelectedIndexChanged="Language1_SelectedIndexChanged" runat="server"> <asp:ListItem value="auto">Autoasp:ListItem> <asp:ListItem Value="en-US">Englishasp:ListItem> <asp:ListItem Value="zh-sg">Chineseasp:ListItem> <asp:ListItem Value="ru">Russainasp:ListItem> asp:DropDownList> <asp:Calendar ID="Calendar1" runat="server">asp:Calendar> div>asp:Content
in global.asax
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
Dim lang As String = String.Empty Dim cookie As HttpCookie = Request.Cookies("lang") If Not (cookie Is Nothing) AndAlso Not (cookie.Value Is Nothing) Then
lang = Request.Form(cookie.Value)
End IfThread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(lang)
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(lang)
End Subin .vb
Imports System.Globalization
Imports System.Threading
Public Class _Default Inherits System.Web.UI.Page
Protected Overrides Sub InitializeCulture() Dim lang As String = Request("Language1") If Not lang = "auto" Then If lang IsNot Nothing Or lang <> "" ThenThread.CurrentThread.CurrentUICulture =
New CultureInfo(lang)Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(lang)
End If End If End Sub Protected Sub Language1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Dim cookie As HttpCookie = New HttpCookie("lang")cookie.Value = Language1.UniqueID
Response.SetCookie(cookie)
End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Language1.SelectedItem.Value = "auto" ThenThread.CurrentThread.CurrentUICulture = CultureInfo.CurrentCulture
End If End SubEnd
Class
No comments:
Post a Comment