asp.net 4.0 intellisense 无法识别 vs2010 中添加到全局资源文件中的新字符串
这是对这里所有人的一个问题。我对 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能还需要将字符串添加到 resx 的相应设计器文件中。
You may need to add your string to the resx's corresponding designer file as well.