繁体   English   中英

Web应用程序App_LocalResources无法正常工作

[英]Web Application App_LocalResources Not Working

我在外部程序集中包含大量的aspx页面,这些页面是通过custoer PathProvider加载的,除了页面的本地资源外,其他所有页面都工作正常。

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

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

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

非常感谢您的帮助,这真让我发疯。

附加信息

因此,welcome.aspx包含在程序集OliveERP.Common中,并命名为welcome.aspx,因为使用自定义路径提供程序加载了它,所以它具有Build Action = Embedded Resource。 OliveERP.Common有一个App_LocalResources文件夹,其中包含welcome.aspx.resx,页面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而不是Paul

似乎以下是您的问题

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

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

当标签的资源键为welcomeLabelResource1时,则在resx文件中,Text属性应具有资源字符串welcomeLabelResource1.Text。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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