PC Review


Reply
Thread Tools Rating: Thread Rating: 5 votes, 4.20 average.

Re: Resource files in ASP.net

 
 
SamIAm
Guest
Posts: n/a
 
      20th Aug 2003
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

"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

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

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

assembly
> 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

assembly
> to look in that one when it cannot find the resource?? I try compiling the
> ASP.net 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
>
>

http://msdn.microsoft.com/library/en...asp?frame=true
>
> The code line in question is
>
> Thread.CurrentThread.CurrentCulture =
> CultureInfo.CreateSpecificCulture(Request.UserLanguages[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

have
> 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
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Scan Assembly for Resource Files + Scan Resource File for Keys JezB Microsoft C# .NET 0 21st May 2004 05:29 PM
can I call getString() to get a string from a separate resource file instead of embedded resource? babylon Microsoft Dot NET Framework 2 7th Oct 2003 04:13 PM
How to print the Resource Kit Documentation? Where to download a printable Resource Kit Documentation? Where to download any printable Windows XP Documentation? Dmitriy Kopnichev Windows XP Help 3 19th Aug 2003 01:10 AM
How to print the Resource Kit Documentation? Where to download a printable Resource Kit Documentation? Where to download any printable Windows XP Documentation? Dmitriy Kopnichev Windows XP Basics 3 19th Aug 2003 01:10 AM
How to print the Resource Kit Documentation? Where to download a printable Resource Kit Documentation? Where to download any printable Windows XP Documentation? Dmitriy Kopnichev Windows XP General 3 19th Aug 2003 01:10 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:37 PM.