I am having a weird issue that I can't seem to fix. I am using WebForms and .NET 4.5.
I have a bunch of Images in an Images folder in my root directory. These images are each in a folder corresponding to some local. It looks like this.
Root
-Images
-en-US
-flag.jpg
-es-MX
-flag.jpg
I am using resource files to store the image paths.
Now the actual issue is that I am unsure how to use relative paths to define the img src in conjunction with the resource file. Normally I could put runat="server" in the img tag and that would let me specify src="~/somepath but since I am using an asp literal as part of the source it does not seem to interpret the tag correctly. If I don't use the ~ (root), the resource wont load as soon as the user changes to a page that is not in the root directory because it tries to load it based on the new location. For example: someurl/UserPages/Images/flag.jpg <= should be someurl/Images/Flag.jpg.
Here is what my img tag looks like:
<img src="~/Images/<asp:Literal ID="test" meta:resourcekey="test" runat="server" Text="" />" runat="server" alt="Flag" height="42" width="42" />
That does not work at all because it interprets the path as
http://ipaddr:port/~/Images/
I have tried implementing this using jQuery to set the src of the img tag and it did not fix the problem.
These are some of the KB articles I have tried to use to fix my problem with no success.
http://msdn.microsoft.com/en-us/magazine/cc163566.aspx
HTML img and ASP.NET Image and relative paths
How to use image resource in asp.net website?
http://forums.asp.net/t/1677822.aspx/1
Thanks in advance for any help you can give.
EDIT:
I tried putting images in the resource file itself but after some digging I found that this is not a good solution for web applications. Still stuck with my original problem. :(
Still no luck!