How can I use a .NET resource file to change the webform language?

As long as you have your resource strings reference applied to the .NET control Text properties, your web form will be able to retrieve the correct string from the associated resource file according to your current web form culture code.

  1. Create the default resource file (e.g. MyResource.resx.

  2. Create the alternate language for the resource file based on the language code. For example, for French Canada, create another resource file named MyResource.fr-CA.resx.

  3. Apply the resource string reference to your .NET control, for example:
    <asp:Label ID="Label1" runat="server" Text="<%# Resources.MyResource.strDescription %>"></asp:Label>

  4. Set your web form language by setting the culture code. For example, for French Canada:
    Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-CA");