简体   繁体   English

如何接收ASP.NET LocalResources resx字符串

[英]How to receive ASP.NET LocalResources resx string

I have in my ASP.NET Web Forms Application resx file localized in App_LocalResources\\fr.aspx.resx with key value: hello_world. 我的ASP.NET Web窗体应用程序resx文件位于App_LocalResources \\ fr.aspx.resx中,其关键值是:hello_world。

Now I want to use it on my ASPxLabel on class Page.aspx, so I simply: 现在,我想在类Page.aspx的ASPxLabel上使用它,因此我只需:

<dx:ASPxLabel ID="0" runat="server" Text="<%$ Resources:fr, hello_world %>"></dx:ASPxLabel>

but I have error: Parser Error Message: The resource object with key 'msg' was not found. 但是我有错误:解析器错误消息:找不到键为'msg'的资源对象。

I am sure that fr.aspx.resx is publicated, but still got Parser Error. 我确定fr.aspx.resx是公开的,但仍然收到解析器错误。 What I am doing wrong? 我做错了什么?

First of all check the name of your resource file. 首先检查资源文件的名称。 It has to follow the following naming convension 它必须遵循以下命名约定

pageName.extension.language.resx

If you aspx page name Page.aspx, then the you should have resource files with the following name.(You can add resource files for further language and culture) 如果您将aspx页面名称命名为Page.aspx,则您应该具有以下名称的资源文件。(您可以添加资源文件以用于进一步的语言和文化)

Page.aspx.fr.resx

Check whether you follow this convension or not. 检查是否遵循此惯例。

To you this resource in the aspx page you have to follow the convension as below 在aspx页面中向您提供此资源,您必须遵循以下惯例

<%$Resources:Class,ResourceID%>

where Class is the name of resource file, if it is compiled as class, otherwise this can be ignored. 其中Class是资源文件的名称,如果将其编译为class,则可以忽略。 ResourceId is the key in the resource file. ResourceId是资源文件中的键。 In your code you are setting the resource as below. 在您的代码中,您将如下设置资源。 Check whether the resource file has a codebehind with the class name fr. 检查资源文件是否具有类名fr的代码后面。

Text="<%$ Resources:fr, hello_world %>">

For more details you can visit the following link http://msdn.microsoft.com/en-us/library/ms227427(v=vs.90).aspx 有关更多详细信息,您可以访问以下链接http://msdn.microsoft.com/zh-cn/library/ms227427(v=vs.90).aspx

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

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