App_localresources not working with directories

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shnizle
    New Member
    • Apr 2009
    • 16

    #1

    App_localresources not working with directories

    hey, cant find how to solve this thing,

    i have a test project with the following directory structure:


    /root/pages/default.aspx
    /root/App_LocalResour ces/default.aspx.re sx
    /root/App_LocalResour ces/default.aspx.fr .resx

    using the following simple code:

    Code:
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestLocale._Default" UICulture="auto:en-US" Culture="auto:en-US"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="Label" meta:resourceKey="Label1"></asp:Label> </div> </form> </body> </html>
    at the resx file i have simple mapping for Label1.Text ,

    The problem: for ssome reason ASP.NET can't find local resources when my default page is not at the root folder in the project,
    when i place the default.aspx in the root project the localization works, when i place the default.aspx inside a folder it doesnt work
    i have been searching everywhere and couldnt find how to make it work when using folders.

    any kind of help would help!

    thank you.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Check out this article: ASP.NET Web Page Resources Overview.

    Currently you are using Local Resource Files and these resource file are found relative to the page that uses them.

    I think you might be interested in using Global Resource Files instead...but you should decide after reading the article.

    -Frinny

    Comment

    • shnizle
      New Member
      • Apr 2009
      • 16

      #3
      Originally posted by Frinavale
      Check out this article: ASP.NET Web Page Resources Overview.

      Currently you are using Local Resource Files and these resource file are found relative to the page that uses them.

      I think you might be interested in using Global Resource Files instead...but you should decide after reading the article.

      -Frinny
      I have read this article a few times also watched some video tutorials , i need to use local resources the question is why it doesn't work if my page is inside a directory and not in the root folder of the web application.

      how do i make it work with folders???

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Both global and local resources are implemented using a very particular folder naming scheme that allows ASP.NET to dynamically find and compile your .Resx resources as part of the pre-compilation for the Web site.

        This means that resources can be deployed easily with your application and ASP.NET will handle compilation and placement of the resource assemblies.

        The scheme works with an App_GlobalResou rces folder at the root of the Web site and an App_LocalResour ces folder for each directory of the site.

        You cannot change this structure because ASP.NET will not be able to locate the resources since the resources are located relative to the page that uses them. Since you are using local resources, your resources must be it a folder called App_LocalResour ces that is in the same directory as the web page that uses them.


        Have you tried creating an App_LocalResour ce folder within the folder where you are moving your page to? Did you move the resources for the page into the App_LocalResour ce folder that is in the new folder?


        -Frinny

        Comment

        • shnizle
          New Member
          • Apr 2009
          • 16

          #5
          thanks alot it worked

          Comment

          • abdul Haseeb
            New Member
            • Feb 2016
            • 1

            #6
            It worked for me

            Thank You. It worked for me

            Comment

            Working...