简体   繁体   中英

Web Application App_LocalResources Not Working

I have a number of aspx pages contained in external assemblies which are loaded via a custoer PathProvider, all works fine with the exception of local resources for the pages.

So for example, I have a project Paul.Pages, within Paul.Pages there are a number of aspx pages, these are all embedded resources and are loaded view PaulPathProvider.

I have page welcome.aspx which has a single lable welcomeLable (and I have set the Text property to "Hello World") in Paul.Pages, I have generated local resources for this page and now in Paul.Pages I also have a App_LocalResources folder with welcome.aspx.resx, in the .resx file I have welcomeLabelResource1.Text = "Hello Paul".

When the page loads I would expect to see "Hello Paul" but actually it displays "Hello World" implying the resource string is not being loaded, I have tried setting the welcome.aspx.resx to Embdedded Resource but it makes not difference.

Any help is much appreciated, this is driving me nuts.

Addiontal Info

So the welcome.aspx is contained in an assembly OliveERP.Common and is named welcome.aspx, this has Build Action = Embedded Resource as it is loaded using a custom path provider. The OliveERP.Common has a App_LocalResources folder containing welcome.aspx.resx the page html is

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="welcome.aspx.cs"     Inherits="OliveERP.Common.welcome" culture="auto" meta:resourcekey="PageResource1"     uiculture="auto" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label runat="server" ID="welcomeLabel" Text="Hello World"     meta:resourcekey="welcomeLabelResource1" />
    </div>
    </form>
</body>
</html>

but page still displays Hello World not Hello Paul

seems the following is your problem

in the .resx file I have welcomeLabel.Text = "Hello Paul".

<asp:Label runat="server" ID="welcomeLabel" Text="Hello World"     meta:resourcekey="welcomeLabelResource1" />

When your label's resourcekey is welcomeLabelResource1 then in your resx file you should have a resource string welcomeLabelResource1.Text for the Text property.

可能您的资源文件为“嵌入式资源”,请尝试使它们成为“内容”文件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM