相反,我更愿意在我的 .aspx 页面中这样做: ...但-6ren">
gpt4 book ai didi

c# - 显示没有 Label 或 Literal 控件的 Resource 的值

转载 作者:可可西里 更新时间:2023-11-01 07:51:23 27 4
gpt4 key购买 nike

如何在没有 ASP.NET 控件的情况下显示资源的值,即我想避免这种情况:

<asp:Label text="<%$ Resources: Messages, ThankYouLabel %>" id="label1" runat="server" />

相反,我更愿意在我的 .aspx 页面中这样做:

<%$ Resources: Messages, ThankYouLabel %>

...但我不能,抛出解析器错误:

Literal expressions like '<%$ Resources: Messages, ThankYouLabel %>' are not allowed.
Use <asp:Literal runat="server" Text="<%$ Resources: Messages, ThankYouLabel %>" /> instead.

最佳答案

使用HttpContext.GetGlobalResourceObject相反:

<asp:Label text='<%= GetGlobalResourceObject("Messages", "ThankYouLabel") %>' 
id="label1"
runat="server" />

关于c# - 显示没有 Label 或 Literal 控件的 Resource 的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5229472/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com