ASP.NET 2.0, Images and resources

S

schneider

Hi all,

I'm facing some problems using images from resources.
I have a resource file "MyResources.resx" in the App_GlobalResources
folder. It contains a string resource (here: "TheAlternateText" for
the corresponding ImageButton-property) and an image resource
("TheImage") which should be displayed on the ImageButton.
Now I add AlternateText="<%$ Resource: MyResources, TheAlternateText
%>" and ImageUrl="<%$ MyResources, TheImage %>" to the asp:ImageButton-
Tag.
When I run the page, the alternate text is displayed correctly, but
the image is not displayed.
Using a local resource and meta:resourcekey="ImageButton1" produces
the same results.
Any ideas what I'm doing wrong?
Thanks in advance.

Cheers,
Hannes
 
B

bruce barker

you are setting the image url to image content rather than the image.
use ClientScript.GetWebResourceUrl() to calc the url.

-- bruce (sqlwork.com)
 
S

schneider

Could you please post some sample code? I don't get it to work.
I have a web page Default.aspx. I created the App_LocalResource folder
in this directory. There, I created a resource file Default.aspx.resx
to which I added an image. Now I want the image to be displayed by an
<asp:Image /> control in Default.aspx. What do I have to do? I tried

string url = Page.ClientScript.GetWebResourceUrl(my_img.GetType(),
"the_img");
my_img.ImageUrl = url;

but it doesn't work. I'm sure my fault is a trivial one, but I'm
actually going nuts. ASP.NET Version is 2.0.

Cheers, Hannes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top