扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Default2" title="Untitled Page" Culture="auto" meta:resourcekey="PageResource1" UICulture="auto" %> ………… <asp:Localize ID="Localize1" runat="server" meta:resourcekey="Localize1Resource1"></asp:Localize> ********************************************************************* |
<asp:Button ID="Button1" runat="server" meta:resourcekey="Button1Resource1" Text="Button1" /><br /> <asp:GridView ID="GridView1" runat="server" meta:resourcekey="GridView1Resource1"> <Columns> <asp:BoundField HeaderText="Header1" meta:resourcekey="BoundFieldResource1" /> <asp:BoundField HeaderText="Header2" meta:resourcekey="BoundFieldResource2" /> </Columns> </asp:GridView> |
Private SupportedLanguages As String() = {"en-us", "fr-fr"} Public Const LANGUAGE_COOKIE_NAME As String = "UserLanguage" Sub Application_AcquireRequestState(ByVal sender As Object, ByVal e As EventArgs) Dim languageCookie As HttpCookie = Request.Cookies(LANGUAGE_COOKIE_NAME) Dim language As String = String.Empty If (languageCookie Is Nothing) Then Dim userLanguages As String() = Request.UserLanguages Dim index As Integer For i As Integer = 0 To userLanguages.Length - 1 index = Array.IndexOf(SupportedLanguages, userLanguages(i)) If index >= 0 Then language = SupportedLanguages(index) Exit For End If Next If language = String.Empty Then _ language = SupportedLanguages(0) Response.Cookies.Add(New HttpCookie(LANGUAGE_COOKIE_NAME, language)) Else language = languageCookie.Value End If Dim culture As CultureInfo = New CultureInfo(language) System.Threading.Thread.CurrentThread.CurrentUICulture = culture End Sub |
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click SetLanguage("fr-fr") End Sub Protected Sub SetLanguage(ByVal language As String) Response.Cookies(Global.ASP.global_asax.LANGUAGE_COOKIE_NAME).Value = language Dim culture As CultureInfo = New CultureInfo(language) System.Threading.Thread.CurrentThread.CurrentUICulture = culture Server.Transfer(Request.Path) End Sub |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者