asp.net.ph

Skip Navigation LinksHome > ASP.NET Applications > ASP.NET Globalization and Localization > ASP.NET Web Page Resources

Resource Files Overview

ASP.NET Web Applications   ASP.NET Globalization


A resource file is basically an XML file used for storing strings that must be translated into other languages.

Resource files typically contain user interface strings such as label and button captions, as well as references to other resources such as image file paths.

Resource files in ASP.NET have a .resx extension.

Essentially, a resource file is made up of a list of name=value pairs, where each pair is treated as an individual resource that can be read by an ASP.NET page by its name. For example

lblGreeting = Bienvenue!
btnSearch = Recherche
imgFlag = ~/travel/images/flags/countries/FR.gif

At design time, ASP.NET provides a way for authors to create a page that can retrieve the content from these files. At run time, the resource expressions defined in the ASP.NET page are replaced by values from the appropriate resource file.

Global and Local Resource Files

In ASP.NET, you can create resource files that are either global or local in scope.

Global resource files are available to any page or component within a Web site. This means that you can read and use the contents of the resource file from any page or component that is within the site structure.

Local resource files, on the other hand, are associated with a single Web page, user control, or master page, and contain the resources for only that page.

The procedure for creating both types of resource files are the same. The only difference is in the format of their filenames, and in which folders they must be stored.

Global Resource Files

A global resource file is one that applies to an entire ASP.NET site.

If you are creating a global resource file, you must have a folder named App_GlobalResources. There can only be one App_GlobalResources folder in an application, and it must be located as a subdirectory of the application root directory.

Any .resx file stored in this folder has global scope.

Additionally, ASP.NET generates strongly typed objects for a global resource, which gives developers a simple way to programmatically access resource content.

Local Resource Files

A local resource file is one that applies to only one ASP.NET page ( an ASP.NET page with the extension of .aspx, .ascx, .master, and so on ).

If you are creating a local resource file, you must have a folder named App_LocalResources that must be located as a subdirectory where the associated ASP.NET page, user control or master page resides. There can be any number of these folders in an application, and they can be located at any level in the application.

Local resource files are associated to a specific Web page by having the same filename as that of the Web page, with the appropriate language or language and locale quantifier.

More ...
Back to top


© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note