Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: Resource files in

Thread Tools

Re: Resource files in

Posts: n/a
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 =

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

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

That should get you going!


"ash" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> ok this may seem like a simply question but Im trying to find out how to

> the DEFAULT resource satellite to load in an application. I
> understand the hub and spoke architecture and all the rest of it but I

> understand how to do this bit
> " To use resources in ASP.NET pages, first create a parallel main

> to store your application's resources. This assembly will contain the
> DEFAULT or NEUTRAL resources for the application. "
> How do I create a parallel main assembly and how do I tell my main

> to look in that one when it cannot find the resource?? I try compiling the
> project including .resources/.resx file without success I even try
> including the resource satellite still without success. Im sure its
> something simply like a project property that you can set but for the life
> of me I cannot find it.
> Ive followed all the instructions from what MS has to say about it
> The code line in question is
> Thread.CurrentThread.CurrentCulture =
> CultureInfo.CreateSpecificCulture(Request.UserLang uages[0]);
> it works when I set my browser to a language that Ive created a satellite
> resource for. However, if I set my browser language to something that I

> not supported and the satellite resource doesnt exist it breaks when I try
> to access something from the resourcemanger...
> What have I missed or do I have to write my own code to handle it???
> Many thanks in advance
> Best Regards
> Ashley Rajaratnam

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Resource expression to access resource located in library Heinrich Moser ASP .Net 1 03-27-2008 04:25 PM
Very annoying error: Access to the path is denied. ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity Jay ASP .Net 2 08-20-2007 07:38 PM
source files vs. resource files Jackie C++ 3 01-28-2006 09:52 PM
Resource manager problem: naming for embedded resource. Dirc Khan-Evans ASP .Net 1 10-17-2005 12:52 PM
The system cannot locate the resource specified. Error processing resource avishosh XML 2 08-08-2004 06:28 AM