Localize Web Server Control Overview
You can add a Localize Web server control to your ASP.NET Web page when you want to display localized text in a specific area on your page.
Comparing the Localize Control to the Literal Control
The Localize control is identical to the Literal Web server control and similar to the Label Web server control. While the Label control allows you to 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 in the Literal Control
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<b>
. Encoding is useful when you want the browser to display markup rather than interpret it. Encoding is also useful for security, to help prevent malicious markup from being executed in the browser, and 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 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 your .resx files in folders called App_GlobalResources and App_LocalResources in the root of your application. If you need 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 ExampleLocalizedStrings.fr.resx.
For more information about expressions, see ASP.NET Expressions Overview. For information about resource files, see Resources in ASP.NET Applications. For a code example that uses regular expressions in the Localize control, see Localize Web Server Control Declarative Syntax.
See Also
Reference
Localize Web Server Control Declarative Syntax
Localize
Concepts
Resources in ASP.NET Applications
ASP.NET Expressions Overview