Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
1 like 0 dislike
329 views
in .Net Framework by 19 32 39

I have an application in which I need to use a resource file to easily update values and text dependent on the language selected.

How to create resource file in ASP.NET?


1 Answer

1 like 0 dislike
by 19 32 39
edited by

What is Resource File?

A resource file is a XML file that contains a key-value pair as an individual resource that used to:

  1. Translate into multiple languages.
  2. Resource values can be dynamically updated, such as page titles, error messages, and label text, once the website is published.

we will show you how to create a Global Resources file in ASP.NET that allows for quick dynamic modifications and supports many languages, as well as how to implement it.

Global resource files can be read from any page or component in the application; however, they must be saved under App_GlobalResources at the application's root.

How to create a resource file?

  1. In solution explorer, right click on the root of the web application click Add, then click Add ASP.NET folder, then select App_GlobalResources folder
  2. Right click on App_GlobalResources folder and click on add new item

  3. Add new item window, chose Resources file and give it any name with .resx extension

  4. Fill the resource file with key / value pairs

How to use a resource?

You can access resource values from your ASP.NET code-behind files or views.

<h1> @Resources.Labels.Login </h1>
If you don’t ask, the answer is always NO!
...