【问题标题】:Web Application App_LocalResources Not WorkingWeb 应用程序 App_LocalResources 不工作
【发布时间】:2014-09-02 10:44:18
【问题描述】:

我有一些包含在外部程序集中的 aspx 页面,这些页面是通过客户 PathProvider 加载的,除了页面的本地资源外,所有页面都可以正常工作。

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

我有一个页面welcome.aspx,它在Paul.Pages 中有一个标签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 但它没有区别。

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

附加信息

因此,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 而不是 Hello Paul

【问题讨论】:

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


【解决方案1】:

似乎以下是你的问题

在 .resx 文件中,我有 welcomeLabel.Text = "Hello Paul"。

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

当你的标签的资源键是welcomeLabelResource1 时,在你的resx 文件中你应该有一个资源字符串welcomeLabelResource1.Text 作为Text 属性。

【讨论】:

  • 对不起,这是一个错字,资源文件实际上是welcomeLabelResource1.Text = "Hello Paul"
  • 下一步是查看您的项目的文件夹结构,如 meta.stackexchange.com/questions/147467/… 以了解您的 aspx 和 resx 文件的位置
【解决方案2】:

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

【讨论】:

    猜你喜欢
    • 2011-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多