ASP.NET 中内联标记的全球化差异
使用内联写入标签而不是资源标签有什么优点/缺点吗?示例:
<%=Resources.Site.SampleString %>
在任何 MSDN 示例中看到的资源标记(表达式标记):
<asp:Literal id="Literal1" runat="server" text="<%$ Resources:Site, SampleString %>" />
我发现第一个选项更容易使用,并且它具有 IntelliSense,但也许它的功能不一样?
Is there any advantage/downfalls between using the inline write tag instead of the resource tag? Example:
<%=Resources.Site.SampleString %>
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这些方法的功能完全相同。后者只是调用第一个;在后台生成强类型资源访问代码是有原因的。因此,您可以使用任何您喜欢的方法。
顺便说一句,还有另一种方法 - 通过使用 meta:resourcekey 属性。所以你应该能够写:
并且一切都应该完全相同。
编辑隐式本地化。
我忘记提到的是,使用 meta:resourcekey 必须满足某些条件。条件是:
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.
By the way, there is also another way - by using meta:resourcekey attribute. So you should be able to write:
and it all should work exactly the same.
EDIT on implicit Localization.
What I forgot to mention, is that with meta:resourcekey certain conditions have to be met. The conditions are:
一段时间后我意识到
<%=Resources.Site.SampleString %>
方法没有设计器支持(这是可以理解的)。这并不困扰我,但这是一个区别(对于未来的读者)。因此,如果您需要或想要设计师支持,则需要第二种选择。
I realised after some time that the
<%=Resources.Site.SampleString %>
method does not have designer support (which is understandable). This doesn't bother me, but it is a difference (for future readers).So if you need or want designer support, the second option would be necessary.