How do I display the value of a resource without a ASP.NET control, i.e. I want to avoid this:
<asp:Label text="<%$ Resources: Messages, ThankYouLabel %>" id="label1" runat="server" />
Instead I would prefer to do just this in my .aspx pages:
<%$ Resources: Messages, ThankYouLabel %>
... but I can’t, a parser error is thrown:
Literal expressions like '<%$ Resources: Messages, ThankYouLabel %>' are not allowed.
Use <asp:Literal runat="server" Text="<%$ Resources: Messages, ThankYouLabel %>" /> instead.
It's not possible. you have to use atleast
Literal
, Another option is to useGetGlobalResurceObject
, so that you can use directly in a page.In code behind You can Use
and also
and then use a simple aspnet variable in your Asp.net Markup like <%= Resourcevalue %>
The you can assign your resource value to your Aspnet Variable like
Use HttpContext.GetGlobalResourceObject instead:
Another method is :-