【发布时间】:2011-03-08 07:12:44
【问题描述】:
如何在没有 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.
【问题讨论】:
-
按照建议使用
Literal有什么问题? -
它使视图状态膨胀,我想将页面修剪到绝对最小值。我还认为,如果我真的不需要额外的控件时可以跳过它们,它会增加可读性。