在ASP.NET内联标签全球化的区别 [英] Globalization difference in inline tags in ASP.NET

查看:152
本文介绍了在ASP.NET内联标签全球化的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有使用内联写标签,而不是资源的标签之间的任何优势/挫折?例如:

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内联标签全球化的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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