O'Reilly logo

Professional ASP.NET 3.5 AJAX by Matt Gibbs, Dan Wahlin, Bill Evjen, Dave Reed

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

13.7. Script Localization with Static Files

When working with the localization of your ASP.NET AJAX applications, another important aspect of localization is in how the scripts themselves are localized. For instance, if alerts and other items in your scripts require localization, you can perform localization to make a script for each language or culture that you are working with to get your ASP.NET page to work with the correct script based upon the end user's culture setting.

To show an example of this in action, Listing 13-15 provides a simple ASP.NET application that makes use of server-side JavaScript files.

Example 13-15. Localizing client-side JavaScript files
<%@ Page Language="C#" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Script Localization</title>

    <script type="text/javascript">

        function pageLoad() {
            populateItems();
        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server"
         EnableScriptLocalization="true">
            <Scripts>
                <asp:ScriptReference Path="~/Scripts/ScriptLocalization.js"
                 ResourceUICultures="fi-FI" />
            </Scripts>
        </asp:ScriptManager>
        <span id="Label1"></span><br />
        <span id="Label2"></span>
    </div>
    </form>
</body>
</html>

This page is quite simple in that only two <span> elements are populated by a script (shown shortly) that contains the function populateItems(). Since you are going to want your application to be localized based on the end user's culture setting in their ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required