What is a Resource File?

A resource file may contain a collection of icons, menus, dialog boxes, strings tables, user-defined binary data and other types of items.
Once compiled into a suitable format, a resource file can be embedded directly into an executable file, producing a single EXE containing both code and resources. At run-time, the application can use the resource items in the embedded file. The process of creating a resource is straightforward, and is similar to compiling a PowerBASIC program.
While resource files are still supported, usage of the #RESOURCE metastatement simplifies adding resources to your program. With the #RESOURCE metastatement you can add resource data inline, right in your basic source code. There is no need to create a resource file, compile it, and then link it into your source. All this done automatically when you use the #RESOURCE metastatement.
The following sections describe the (manual) techniques involved in compiling resource scripts into a usable format, and describe the Resource Script.

  • A resource file is a XML file that contains the strings that we want to
    1. Translate into different languages.
    2. Can be updated dynamically so that user themselves can modify values in resource files once the application is deployed on the server without re-compiling the entire application itself.
  • The resource file contains key / value pairs.
  • Each pair is an individual resource.
  • Key names are not case sensitive.

Types of Resources:
There are two types of resources

  1. Local Resources
  2. Global Resources

Local Resources:
Local resource is specific to a single Web page and used for providing versions of a Web page in different languages.
Local resources must be stored in the App_LocalResource subfolder of the folder containing the web page. Because you might have local resources for every page in your web application, you might have App_LocalResource subfolders in every folder.
Resource file names should be like [.langauge].resx. Some examples of local resource files are, Mypage.aspx.ex.resx and Mypage.aspx.de.resx. Default.aspx.resx is the base resource file to use if no other resource file matches with the user’s current culture.
If you want to create local resources for a page, open the design view of the page and then from Tool Menu select Generate Local Resource. You will then see that a resource file is automatically created in the corresponding App_LocalResource folder.
Global Resources:
The App_GlobalResource folder can be read from any page or code that is anywhere in the web site. Global resources must be stored in the App_GlobalResource folder at the root of the application. We should use the App_GlobalResource folder when we need a single resource for multiple web pages. We candefine ASP.NET control properties by manually associating them with resources in global resource files.You can add a global resource file by right clicking on the App_GlobalResource folder and clicking on Add Items. Add .resx files as resources.

Tagged , . Bookmark the permalink.

Leave a Reply