代码改变世界

Asp.net 语言设置

2013-04-24 00:29  Ecin  阅读(280)  评论(0编辑  收藏  举报
  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