有没有使用内联写标签,而不是资源的标签之间的任何优势/挫折?例如:
Is there any advantage/downfalls between using the inline write tag instead of the resource tag? Example:
<%=Resources.Site.SampleString %>所看到的任何MSDN例子中的资源标记(如pression标签):
The resources tag (expression tag) as seen in any MSDN example:
<asp:Literal id="Literal1" runat="server" text="<%$ Resources:Site, SampleString %>" />我找到的第一个选项更容易使用,它有智能感知,但也许它不会起作用一样?
I find the first option far easier to use, and it has IntelliSense, but maybe it won't function the same?
推荐答案这些方法的功能完全相同。后者只是调用第一个;还有就是在后台生成强类型资源的访问code的理由。因此,你可以使用你取悦任何方法。
These methods will function exactly the same. The latter simply calls first one; there is a reason why strongly-typed resources access code is being generated in the background. Therefore you can use whatever method you please.
对了,还有另一种方式 - 通过的元:获取ResourceKey属性。所以,你应该能够写:
By the way, there is also another way - by using meta:resourcekey attribute. So you should be able to write:
<asp:Literal id="Literal1" runat="server" meta:resourcekey="SampleString" text="Default one" />而这一切应该工作完全相同。
and it all should work exactly the same.
修改隐式本地化。
我忘了提,就是与元:获取ResourceKey一定的条件必须得到满足。的条件是:
What I forgot to mention, is that with meta:resourcekey certain conditions have to be met. The conditions are:
- 值从App_LocalResources文件拍摄,因此相关的资源文件,有存在的必要
- 相关资源文件名必须是pagename.resx,例如:为Default.aspx.resx,Default.aspx.es.resx
- 的资源文件必须包含resourcekey.propertyname形式键,例如SampleString.Text,SampleString.ID(虽然我不会本地化控制的ID) 由于是如何产生的资源
- ,上面提到的密钥必须存在于不变的资源文件(为Default.aspx.resx),否则将不进行本地化。
更多推荐
在ASP.NET内联标签全球化的区别
发布评论