您可以在resource.resx文件中检索文本块吗? [英] Can you retrieve blocks of text in resource.resx files?

查看:66
本文介绍了您可以在resource.resx文件中检索文本块吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个巨大的项目需要使用各种不同的语言进行工作.因此,我们已决定为此目的使用resource.resx文件.

我知道按钮,标签和其他属性可以通过选择正确的CultureID轻松地从资源文件中获取正确的值.但是同时,我还有其他一些内容(不是标签或按钮)可以从用于翻译的资源文件中受益.那就是标题标签< h>中的内容.或Div标签< div>甚至是完整表格,其中包含其单元格内的信息.

有没有一种方法可以从Resource.resx文件中检索代码块(例如整个静态表),并直接在.aspx文件中引用(即:使用)(而不是后面的代码)而不会成为文本按钮或标签的属性?

感谢您的帮助.

Hello all,

I have a huge project to work on in various different languages. So we have decided to use resource.resx files for this purpose.

I understand that buttons, labels, and other properties can easily obtain the correct value from the resource file by selecting the correct CultureID. But at the same time I have several other content (not labels or buttons) that could benefit from a resource file for translation. That is content in header tags <h> or Div tags <div> or even complete tables with information within their cells.

Is there a way that a block of code (example a whole static table) can be retrieved from a Resource.resx file and be referenced (that is: used) directly in the .aspx file, (not code behind) without being a text property of a button or label?

Thanks for your help.

推荐答案

是的,您可以这样做.您可以像这样使用文字控件:
Yes you can do this. You can use the literal control like this:
<asp:Literal ID="foo" runat="server" Mode="Transform" Text="<h1>Hello</h1>" />


您将获得一个正确呈现的h1元素.您需要做的就是像使用其他任何控件一样,从resx文件中设置Text 属性.另一件事是您可能需要将Mode设置为PassThrough,这取决于您在做什么.


and you''ll get a correctly rendered h1 element. All you need to do is set the Text property from your resx file as you would for any other control. One further thing is you might need to set the Mode to PassThrough, it depends what you are doing.


基思,

感谢您的解决方案,它可以正常工作.经过进一步研究,我还注意到您可以将信息存储在资源文件中,然后使用<%=%>访问该文件.和GetGlobalResourceObject示例:

<%= GetGlobalResourceObject(资源",字段")%>

这样,即使不使用asp:Literal,您存储在资源文件中的任何内容都将被检索并显示.

关于此事的更多信息.

谢谢,

里卡多
Keith,

Thanks for your solution, it works. After further research I also noticed you can store information in the resource file and later access it using the <%= %> and the GetGlobalResourceObject Example:

<%= GetGlobalResourceObject ("Resource", "Field") %>

That way even without using asp:Literal whatever you store in the resource file would be retrieved and displayed.

Just a bit more of information to that matter.

Thanks,

Ricardo


这篇关于您可以在resource.resx文件中检索文本块吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆