13.5. ASP.NET 3.5 Resource Files

When you work with ASP.NET 3.5, all resources are handled by a resource file. A resource file is an XML-based file that has a .resx extension. You can have Visual Studio 2008 help you construct this file. Resource files provide a set of items that are utilized by a specified culture. In your ASP.NET 3.5 applications, you store resource files as either local or global resources. The following sections look at how to use each type of resource.

13.5.1. Making Use of Local Resources

You would be surprised how easily you can build an ASP.NET page so that it can be localized into other languages. Really, the only thing you need to do is build the ASP.NET page as you normally would and then use some built-in capabilities from Visual Studio 2008 to convert the page to a format that allows you to plug in other languages easily.

To see this in action, build a simple ASP.NET page as presented in Listing 13-10.

Example 13-10. Building the basic ASP.NET page to localize
<%@ Page Language="C#" %>

<script runat="server">

    protected void Button1_Click(object sender, EventArgs e)
    {
Label2.Text = TextBox1.Text; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Sample Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="What is your name?"></asp:Label><br /> <br /> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>&nbsp; <asp:Button ID="Button1" runat="server" Text="Submit ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.