簡體   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