Web应用程序App_LocalResources不起作用

时间:2014-09-02 10:44:18

标签: c# asp.net embedded-resource resx

我有许多外部程序集中包含的aspx页面,它们通过客户端PathProvider加载,除了页面的本地资源外,一切正常。

所以例如,我有一个项目Paul.Pages,在Paul.Pages中有一些aspx页面,这些都是嵌入式资源并且都是加载视图的PaulPathProvider。

我的页面welcome.aspx在Paul.Pages中有一个lable welcomeLable(我已将Text属性设置为“Hello World”),我为此页面生成了本地资源,现在在Paul.Pages中我也有一个带有welcome.aspx.resx的App_LocalResources文件夹,在.resx文件中我有welcomeLabelResource1.Text =“Hello Paul”。

当页面加载时,我希望看到“Hello Paul”,但实际上显示“Hello World”暗示资源字符串未加载,我尝试将welcome.aspx.resx设置为Embdedded Resource,但它没有差。

非常感谢任何帮助,这让我疯狂。

Addiontal Info

所以welcome.aspx包含在一个程序集OliveERP.Common中,名为welcome.aspx,它具有Build Action = Embedded Resource,因为它是使用自定义路径提供程序加载的。 OliveERP.Common有一个包含welcome.aspx.resx的App_LocalResources文件夹,页面html是

<%@ 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>

但页面仍然显示Hello World而不是Hello Paul

2 个答案:

答案 0 :(得分:0)

似乎以下是你的问题

  

在.resx文件中我有welcomeLabel.Text =“Hello Paul”。

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

当你的标签的resourcekey是welcomeLabelResource1然后在你的resx文件中你应该有一个资源字符串welcomeLabelResource1.Text用于Text属性。

答案 1 :(得分:0)

可能您的资源文件是“嵌入式资源”,请尝试将它们设置为“内容”文件。