Asp.net 语言设置

  1. 应用程序级别

    <configuration>

    <system.web>

    <globalization uiculture="zh-HK" culture="ja-JP">

    </globalization></system.web>

    </configuration>

    public void Page_Load()

    {

    Response.Write ("Current Culture is " + CultureInfo.CurrentCulture.EnglishName);

    }

  2. 页面级别

    <%@Page Culture="fr-FR" Language="C#" %>

    <% @Import Namespace="System.Globalization" %>

    <html>

    <head>

    </head>

    <script runat="server">

    public void Page_Load()

    {

    Response.Write ("Current Culture is " + CultureInfo.CurrentCulture.EnglishName);

    }

    </script>

    <body></body>

    </html>

     

  3. 线程级别

    public void Page_Load()

    {

    // Display the Current Culture

    Response.Write("Current Culture is " +

    Thread.CurrentThread.CurrentCulture.EnglishName + "<br>");

    // Modify the Current Culture

    Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");

    Response.Write("Changing Culture to " +

    Thread.CurrentThread.CurrentCulture.EnglishName + "<br>");

    }

     

Reference:Set Current Culture Programatically in an ASP.NET Application

本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/ecin/p/3039348.html