asp.net 4.0 intellisense 无法识别 vs2010 中添加到全局资源文件中的新字符串

发布于 2024-12-22 09:34:20 字数 768 浏览 3 评论 0原文

这是对这里所有人的一个问题。我对 ASP.net 很陌生,并且遇到一些代码无法运行的问题。在 App_GlobalResources 文件夹中,我有翻译英语和西班牙语字符串的本地化文件。它们被称为 ls.resx 和 ls-es.resx,是在过去的某个时候设置的。

我被要求向网站添加一些功能,这需要我本地化所有文本,因此我向这些文件添加了新字符串并构建了解决方案。然后我尝试在代码中使用它。

如果我直接在 .aspx 文件中使用本地化文件,它就可以毫无问题地进行本地化。例如,我使用...

<asp:Label ID="LabelFName" runat="server" CssClass="label"
    Text="<%$ Resources:ls, FirstName %>"
    Width="140px"></asp:Label>

但是,如果我转到后面的代码并尝试使用资源文件以编程方式设置字符串,则会遇到问题。例如,如果它是先前输入到 ls.resx 和 ls-es.resx 中的旧字符串,则它可以正常工作...

lblWarning = Resources.ls.warningMissingData;

但是,如果我尝试使用新字符串之一,则智能感知不会拾取它,并且我无法访问它。第一种方法使用 <% %> 效果很好。所以我知道字符串在那里并且构建了部分,我只是无法在部分后面的任何代码中访问它们,而且我不知道为什么它不起作用。

有什么想法可能导致这个问题吗?

a question for all the people here. I am quite new to ASP.net and am having a problem with some code not working out. In the App_GlobalResources folder I have my localization files that translate strings in English and Spanish. They are called ls.resx and ls-es.resx and were setup sometime in the past.

I been asked to add some features to the site and this requires me to localize all the text so I added the new strings to these files and built the solutions. Then I tried to use it in the code.

If I use the localization files directly in the .aspx file it picks up the localization no problem at all. For example I use...

<asp:Label ID="LabelFName" runat="server" CssClass="label"
    Text="<%$ Resources:ls, FirstName %>"
    Width="140px"></asp:Label>

If I go to the code behind however and try to programatically set strings using the resources files I have problems however. If it is an old string that has previously been entered into ls.resx and ls-es.resx it works fine, for example...

lblWarning = Resources.ls.warningMissingData;

However if I try to use one of the new strings it is not picked up by the intellisense and I can not access it. It works fine the first method using <% %> so I know the string is there and the section built, I just can't access them in any code behind sections and I have no idea why it is not working.

Any ideas what could be causing this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

残疾 2024-12-29 09:34:20

您可能还需要将字符串添加到 resx 的相应设计器文件中。

You may need to add your string to the resx's corresponding designer file as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文