Click here to Skip to main content
12,550,379 members (45,035 online)
Click here to Skip to main content
Add your own
alternative version


17 bookmarked

Create Resource Files for ASP.NET Web Sites

, 13 May 2009 CPOL
Rate this:
Please Sign up or sign in to vote.
Introduction to multi language applications based on the .NET Framework







In an ASP.NET Web page, you can set to two culture values, the Culture and UICulture properties. The Culture value determines the results of culture-dependent functions, such as the date, number, and currency formatting, and so on. The UICulture value determines which resources are loaded for the page.


This is a very simple article for those who know object oriented programming.

Using the Code 

The code is arranged in:

  • App_Code mybasePage class
  • App_LocalResources
  • aspx pages

App_Code mybasePage Class 

Class mybasepage is derived from System.Web.UI.Page. Public property CultureName sets cultureName. Set the CurrentUICulture and CurrentCulture properties of the current thread to the UI culture and culture, respectively. The CurrentUICulture property takes a language and culture information string. To set the CurrentCulture property, you create an instance of the CultureInfo class and call its CreateSpecificCulture method.

public class mybasePage : System.Web.UI.Page 
    public mybasePage()
        // TODO: Add constructor logic here
    static string cultureName;

    public static string CultureName
        get { return cultureName; }
        set { cultureName = value; }

    protected override void InitializeCulture()
            Thread.CurrentThread.CurrentCulture =
            Thread.CurrentThread.CurrentUICulture = new
          <td >
              <asp:Label ID="Label1" runat="server" Text="Select Language"></asp:Label>
          <asp:DropDownList ID="DropDownList1" runat="server">
      <asp:ListItem Text="English" Value="en-US"></asp:ListItem>
      <asp:ListItem Text="Marathi" Value="mr-IN"></asp:ListItem>
      <asp:ListItem Text="Gujarathi" Value="gu-IN"></asp:ListItem>
          <td colspan="3">
          <td colspan="3" align="center">
          <asp:Button ID="Button1" runat="server"
          Text="set Language" onclick="Button1_Click"
                   style="height: 26px" />
           <asp:LinkButton ID="LinkButton1" runat="server"
      PostBackUrl="~/Sample.aspx">Go to Sample Page</asp:LinkButton>
protected void Button1_Click(object sender, EventArgs e)
       mybasePage.CultureName = DropDownList1.SelectedItem.Value.ToString();

Go to the sample page. There is a link button to navigate to another page. 

The sample page shows Language setting words.


Creating Resources from a Web Page  

A resource file is an XML file that can contain strings and other resources, such as image file paths. Resource files are typically used to store user interface strings that must be translated into other languages. This is because you can create a separate resource file for each language into which you want to translate a Web page. 

Global resource files are available to any page or component in your Web site. Local resource files are associated with a single Web page, user control, or master page, and contain the resources for only that page.

To generate a local resource file from an ASP.NET Web page: 

  1. Open the page for which you want to create a resource file.
  2. Switch to Design View.
  3. In the Tools menu, click Generate Local Resource. Visual Web Developer creates the App_LocalResources folder if it does not already exist. Visual Web Developer then creates the culturally neutral base resource file for the current page, which includes a key/name pair for each control property or page property that requires localization. Finally, Visual Web Developer adds a meta attribute to each ASP.NET Web server control to configure the control to use implicit localization for more information about implicit and explicit localization.
  4. Type values for each resource that you need in your application, and then save the file.
  5. If the latest resource changes are not displayed, refresh Design view by switching to Source view and then switching back to Design view.
  6. To create resource files for additional languages, copy the file in Solution Explorer or in Windows Explorer, and then rename like:

    Sample.aspx page contains a label. This label text changes if you make a change in the default.aspx page.

Points of Interest  

  • To design the same web site for national/international language.


  • 12th May, 2009: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

India India
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralMy vote of 5 Pin
maxcom11-Dec-12 16:37
membermaxcom11-Dec-12 16:37 
QuestionResource file Pin
Shivarajbk7-Dec-12 0:04
memberShivarajbk7-Dec-12 0:04 
is there any ristrictions in giving file name?
GeneralCreating Plain text resource file entry Pin
meetBinu20-Dec-09 18:18
membermeetBinu20-Dec-09 18:18 
GeneralMy vote of 2 Pin
Samer Abu Rabie13-May-09 20:37
memberSamer Abu Rabie13-May-09 20:37 
QuestionWhat about Culture & UICulture Pin
kanu@adatapost13-May-09 17:27
memberkanu@adatapost13-May-09 17:27 
AnswerRe: What about Culture & UICulture Pin
girishdpatil13-May-09 17:58
membergirishdpatil13-May-09 17:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161021.1 | Last Updated 13 May 2009
Article Copyright 2009 by girishdpatil
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid