Question

My ASP.NET page has some html:

Default.aspx:

<h2><asp:Localize meta:resourcekey="lblTitle" Text="Welcome to so" runat="server"></h2>

Now i want to localize that text. So i've created a resource file Default.aspx.resx. Following the examples of Microsoft, Microsoft, Microsoft, CodeProject, and Stackoverflow i create an lblTitle.Text entry:

enter image description here

Except that little red error indicator's hint says,

The resource name "lblTitle.Text" is not a valid identifier.

How do i localize with asp:Localize? How do i localize with meta:? How do i create a resx?


Update: Renamed App_GlobalResources to App_LocalResources:

enter image description here

Web.config (partial):

<system.web>
        <compilation debug="true" targetFramework="4.0"/>

Update 2: What i don't understand is that i'm following the instructions on MSDN:

To edit the resource file by using the Resource Editor

  1. In Solution Explorer, open Sample.aspx.resx.

    In the Resource Editor, under Value, are the Text properties for each of the controls that you placed onto your page. Changing the value here will change the value for the default culture.

  2. Set ButtonResource1.Text to Edited English Text.

  3. Save the file.

i've also tried

  • lblTitle.Text
  • lblTitle-Text
  • lblTitle_Text
  • lblTitle
  • lblTitleText
Was it helpful?

Solution

You did everything right, but put your ressource file in the wrong folder. Use App_LocalResources instead of App_GlobalResources.

See MSDN for more info on the difference between local and global ressource files:

A local resources file is one that applies to only one ASP.NET page or user control (an ASP.NET file that has a file-name extension of .aspx, .ascx, or .master). You put local resource files in folders that have the reserved name App_LocalResources. Unlike the root App_GlobalResources folder, App_LocalResources folders can be in any folder in the application. You associate a set of resources files with a specific Web page by using the name of the resource file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top