Re: Resource files in ASP.net

Discussion in 'ASP .Net' started by SamIAm, Aug 20, 2003.

  1. SamIAm

    SamIAm Guest

    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" <> wrote in message
    news:...
    > 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-us/cpguide/html/cpconresourcesinasppages.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
    >
    >
     
    SamIAm, Aug 20, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dirc Khan-Evans
    Replies:
    1
    Views:
    914
    Karl Seguin
    Oct 17, 2005
  2. Fredrik Rodin
    Replies:
    2
    Views:
    4,961
    Fredrik Rodin
    Nov 4, 2005
  3. Sanjay Pais
    Replies:
    1
    Views:
    2,402
    Sanjay Pais
    Dec 20, 2005
  4. avishosh
    Replies:
    2
    Views:
    10,625
    avishosh
    Aug 8, 2004
  5. Heinrich Moser
    Replies:
    1
    Views:
    467
    Heinrich Moser
    Mar 27, 2008
Loading...

Share This Page