views:

148

answers:

1

I have som text-content that I want to be able to change without recompiling my project. I have created a resource file and put some text-content in it.

I was under the impression that I could write <%$ Resources:mapLink2 %> wherever I wanted but that doesn't seem to be the case.

The following code in my ascx gives me an error:

<a href="<%$ Resources:mapLink2 %>"><img class="2 selectableImg" src="map_2.gif" /></a>

I only got the error message in Swedish (sorry about that) but I think it might give you some hints of what is going on:

Literala uttryck som "" är inte tillåtna. Använd i stället. vid System.Web.UI.TemplateParser.ProcessError(String message) vid System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding) vid System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)

But if I do:

<a href='<asp:literal runat="server" Text="<%$ Resources:mapLink2 %>"/>'><img class="2 selectableImg" src="map_2.gif" /></a>

it all works out allright.

How come the first version doesn't work? Aren't resource files supposed to work like I want them to in example 1?

A: 

Maybe this only works with server controls? Have you tried setting runat="server" on the a from your first example?

Chris Hynes