views:

40

answers:

1

How can I show an image on a webbrowser control in C#/.NET? I'm doing something like

webBrowser1.DocumentText = "<html><head></head><body><img src=imagelocationURL.png/></body></html>"

but the image doesn't appear. What am I doing wrong?

+1  A: 

I would guess one of two things: either that, as codeka points out, you are missing the quotes (single or double) around imagelocationURL.png and the tag is not rendering; or else you need to examine the location of your .png file. For sure, add the quotes:

webBrowser1.DocumentText = "<html><head></head><body><img src='imagelocationURL.png'/></body></html>" 

Then, try hardcoding the path to your .png file and see if that works:

webBrowser1.DocumentText = "<html><head></head><body><img src='C:/Temp/imagelocationURL.png'/></body></html>"

If the hardcoded path works, then you just need to play around with your code to pull out the equivalent of the hardcoded path.

Steve Elmer