13.4. Client-Side Culture Details

When working with culture on the client side, the culture that is used is the culture that is defined on the server. Therefore, if you have the culture set to en-US on your server, this is the default that is utilized on the client-side operations as well. Consider the example presented in Listing 13-8.

Example 13-8. Viewing dates with a culture setting as set on the server
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Globalization"%>

<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
        Response.Write("Date from the server before setting culture: " +
           DateTime.Now + "<br />");
        System.Threading.Thread.CurrentThread.CurrentCulture =
           new CultureInfo("ru-RU");
        Response.Write("Date from the server after setting culture: " +

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script type="text/javascript">

        function pageLoad() {

            var date = new Date();
            $get('Label1').innerHTML = "Date after setting culture on the client: "
               + date.localeFormat("D");
            alert(String.localeFormat("{0:dddd, dd MMMM yyyy hh:mm:ss tt}",
               new Date()));


    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"
         EnableScriptGlobalization="true" />
        <span id="Label1"></span>

First off, to work with setting the culture on the server, you need to import the System.Globalization namespace. The first thing ...

Get Professional ASP.NET 3.5 AJAX now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.