Re: Resource files in ASP.net

S

SamIAm

Hi Ash

Try the following:
1) Create a folder called ResourceFiles
2) Right click on the new folder and add a new resources file called
appResource.resx (Very NB: Default - If no culture is found)
3) Open the resource file and add a key Hello with value Hello
4) Repeat step 2 and name the new resource file appResources.en-AU.resx
(English - Australia)
5) Add a key Hello with a value Gday Mate
6) Create a new webform and add the following:
using System.Resources;
using System.Reflection;
using System.Threading;
using System.Globalization;

In the Page_Load event add:
String SelectedCulture = "en-AU";
Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture(SelectedCulture);
Thread.CurrentThread.CurrentUICulture =
Thread.CurrentThread.CurrentCulture;

Assembly a = Assembly.GetExecutingAssembly();
ResourceManager rm = new
ResourceManager("MyWebApp.ResourceFiles.appResource", a);

lblHello.Text = rm.GetString("Hello");

That should get you going!

S
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top