This documentation is archived and is not being maintained.

Localize Web Server Control Overview

The Localize Web server control lets you display localized text in a specific area on your page.

This topic contains:

The Localize control is identical to the Literal Web server control and similar to the Label Web server control. Although the Label control lets you apply a style to the displayed text, the Localize control does not. You can programmatically control the text that is displayed in the Localize control by setting the Text property, which is inherited from the Literal control.

Encoding Content

The Localize control supports the Mode property, which specifies how the control handles markup that you add to it. You can set the Mode property to the following values:

  • Transform  Any markup that you add to the control is transformed to accommodate the protocol of the requesting browser. This setting is useful if you are rendering content to mobile devices that use a protocol other than HTML.

  • PassThrough  Any markup that you add to the control is rendered as-is to the browser.

  • Encode  Any markup that you add to the control is encoded using the HtmlEncode method, which converts HTML encoding into its text representation. For example, a <b> tag is rendered as &lt;b&gt;. Encoding is useful when you want the browser to display markup rather than interpret it. Encoding is also useful for security and to help prevent malicious markup from being executed in the browser. It is recommended if you are displaying strings from an untrusted source. For more information, see How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings.

Localizing Text By Using Resource Strings

You can create localized strings to display in the Text property of the Localize control by using an explicit or implicit expression as the value of the property. Expressions are evaluated by using strings that are declared in resource (.resx) files.

Create .resx files in folders named App_GlobalResources and App_LocalResources in the root of your application. If you have to localize strings for multiple languages, you can create additional .resx files with locale information included in the file name. For example, the French version of your resource file would be named

For more information about expressions, see ASP.NET Expressions Overview. For information about resource files, see Localizing ASP.NET Web Pages By Using Resources. For a code example that uses regular expressions in the Localize control, see Localize Web Server Control Declarative Syntax.

Back to top

The following table lists the classes that relate to the Localize control.




The main class for the control.

Back to top