views:

624

answers:

3

I am implementing themes to enable an existing website to be rebranded (logos, colors, images etc.) depending on the requesting URL. I understand how to do that and have got the skins working fine except for some exceptions related to the URLs of images.

Specifically I have a control property that it is not feasible to skin. Prior to implementing themes it looked like this:

<DisplayImageChecked Url="~/Images/BobIcon-Green.png" />

Obviously that will not work with themes. So after much trial and error and reading I am trying to implement it like this:

<DisplayImageChecked Url="~/AppThemes/<%= Page.Theme %>/Images/BobIcon-Green.png" />

However that does not work. The generated html looks like:

<img src="AppThemes/%3C%25=%20Page.Theme%20%25%3E/Images/BobIcon-Green.png"/>

Any pointers in the right direction would be appreciated.

David

A: 

Is there a reason that you can't just dump the images in the same folder as the theme? If you put an image say for example: "image.gif" into the theme folder, then you can simply refer to it directly in your skin.

ImageUrl="image.gif"

This will resolve just fine when you apply this skin on a control in your page. Also much easier than trying to do the dynamic URL thing.

Josh
Unforntunately this does not help as I have master pages involved here as well.
daveywc
+1  A: 

Use the binding syntax inside a databound control (watch the single vs double quotes):

<DisplayImageChecked Url='<%# "~/AppThemes/" + Page.Theme + "/Images/BobIcon-Green.png" %>' />
HectorMac
A: 

You may also use "Images/BobIcon-Green.png" as Url. ASP will take care of resolving the Url to the directory within your theme.

Matthias