ASP.NET 2.0 Unleashed

Using the Localize Control

The ASP.NET Framework includes a control named the Localize control. This control is included in the Framework to make it easier to localize big chunks of text in a page.

For example, the page in Listing 24.25 uses the Localize control in the body of the page.

Listing 24.25. ShowLocalizeControl.aspx

<%@ Page Language="VB" UICulture="auto" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Show Localize Control</title> </head> <body> <form runat="server"> <div> <asp:Localize meta:resourceKey="locBodyText" Runat="server"> Here is the page body text </asp:Localize> <br /><br /> <asp:Literal runat="server"> Here is some literal text </asp:Literal> </div> </form> </body> </html>

The Localize control is very similar to the Literal control (it derives from the Literal control). In Source View, there is nothing that distinguishes the two controls. The difference between the Localize control and Literal control is apparent only in Design View. Unlike the Literal control, the contents of the Localize control can be edited directly on the Designer surface in Design View (see Figure 24.10).

Figure 24.10. Using the Localize control in Design View.

Категории