Little hack to have localized images – ASP .NET

In my current project we are implementing localization to support Spanish. We thought it would be good if we have our header image change as per the language specification selected by the user. Obviously we thought of adding those images under their specific resource files but the problem was how to display them. Although we found the code to display those images dynamically (using Response.ContentType as image and Response.BinaryWrite) we were in search of a better solution. That is when I did this little hack to set the path for the src of the image from the resource file as given below:

<img id="imgTest" runat="server" alt="test image" src="<%$ Resources:ImageFile %>" meta:resourcekey="imgTestResource1"/>

And specified the path of the image to point to specific image files in the respective resource files. Works like a charm. I dont know if this is a good solution but it works fine. I would love to hear your feedback or better solutions if any.

Happy Programming!!!



0 Responses to “Little hack to have localized images – ASP .NET”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: