axWebBrowser not displaying images

T

Tom

VS 2003/C#

Have a axWebBrowser control that will not render images.
Originally our app was just launching IE7 to display an HTML page. The
bitmap images were not displaying - path was correct and HTML was correct.
After converting images to JPG they started displaying OK in IE7. When we
embedded the HTML in the axWebBrowser control it reverted back to the
original behavior - no images.

Images (even bitmaps) rendered OK in firefox...did not get to test in IE6.

TIA...Tom
 
C

Cor Ligthert[MVP]

Tom,

Strange because the AXWebbrowser is nothing more than IE in the OS. It
relys on the IE settings in the OS how it behaves (If you want that or not).

:)

Cor
 
T

Tom

Any idea why IE won't render bitmaps?

Where using a basic img tag:
<img src='formationimages\\formation" + intFormationID + ".jpg'>
 
C

Cor Ligthert[MVP]

Tom,

As an image is not shown in a webpage then it is mostly a question if the
image is on the given place. This can be because your miss in front ..\ or
whatever but that is depending how you did organize that in your webpages.

Cor
 
T

Tom

What you say might be true if the same page did not render properly in
firefox or by simply changing the file type. The problem is IE7. Do you
know how to get IE to accept bitmaps?
 
R

Registered User

Any idea why IE won't render bitmaps?

Where using a basic img tag:
<img src='formationimages\\formation" + intFormationID + ".jpg'>

Would it work if the extension in the example were changed to ".bmp"?

regards
A.G.
 
T

Tom

The axWebBrowser will not render either the bmp or the jpg files. IE 7 will
render the jpg file but not the bmp files. I've even tried converting the
bitmaps to GIF files and it's the same - IE7 OK, axWebBrowser - Not OK.

Here's more...the HTML being sent to the axWebBrowser is a simple table
(below). Our first take on this was to generate an HTML file saved to disk
and launch IE. This will now work for us as we've learned that if we change
our file type to jpg or gif IE is cool with that. When we tried to embed
this report into the app we found that none of the file types display. When
we run the app and right click on the browser control and do a view source,
what displays in notepad is <HTML></HTML>...I don't get that...

Here's the code that loads the browser control (axWeb06):

try

{

StringBuilder sbHtml = new StringBuilder();
axWeb06.Navigate("about:blank", ref _empty, ref _empty, ref _empty, ref
_empty);

_doc = axWeb06.Document as IHTMLDocument2;

//wait for document to load

while (_doc.body == null) Application.DoEvents();

strHitChart = "<table border=1><tr><td colspan=2 align=center><B>HIT CHART "
+ lbHitTeam.Text + " " + lbHitYear.Text + " " + strDowns +
"Downs</td></tr><tr>";

sbHtml.Append (strHitChart);

// database queries follow to get the rest of the data and do subsequent
sbHtml.Append...

//write the HTML to the document's body

_doc.body.innerHTML = sbHtml.ToString();

}

catch(Exception ex)

{

MessageBox.Show("Error generating HIT Chart - " + ex.Message);

}

This is the html result:

<table border=1><tr><td colspan=2 align=center><B>HIT CHART OHIO 2005
1st&2nd Downs</td></tr><tr><td><table><tr><td><b><u>S UNO SL</u>: <font
color=Blue>TOL </font><font color=DeepPink>BSU </font><font
color=LimeGreen>BUFF </font></TD></TR><TR><TD width=400><b>BBPS:<font
color=DeepPink>1 </font><font color=LimeGreen>3 </font>BNCE NKO:<font
color=DeepPink>7 </font>BUB SCRN:<font color=Blue>1 </font></TD></TR><tr><td
align=center><b>9 - 12</b></td></tr> <tr><td><img
src='Formation3.gif'></img> </td></tr><TR><TD width=400><b>ZN:<font
color=Blue>2 </font><font color=DeepPink>1 </font>ZN WK:<font color=Blue>2
</font><font color=DeepPink>4
</font></TD></TR></table></td><td><table><tr><td><b><u>GO UNO</u>: <font
color=Blue>TOL </font><font color=DeepPink>BSU </font><font
color=LimeGreen>BUFF </font></TD></TR><TR><TD width=400><b>Z SWP NKD
WK:<font color=Blue>7 </font><font color=DeepPink>1 </font>Z SWP ROLL TRW
BK:<font color=LimeGreen>1 </font></TD></TR><tr><td align=center><b>3 -
9</b></td></tr> <tr><td><img src='Formation4.gif'></img> </td></tr><TR><TD
width=400><b>FK HND SWP QB CTR T:<font color=LimeGreen>1 </font>Z SWP:<font
color=LimeGreen>2
</font></TD></TR></table></td></tr><tr><td><table><tr><td><b><u>GO UNO
SL</u>: <font color=LimeGreen>BUFF </font></TD></TR><TR><TD
width=400><b>BNCE BT:<font color=LimeGreen>1 </font>STRCH BT:<font
color=LimeGreen>1 </font></TD></TR><tr><td align=center><b>0 -
2</b></td></tr> <tr><td><img src='Formation6.gif'></img> </td></tr><TR><TD
width=400><b></TD></TR></table></td><td><table><tr><td><b><u>GU UNO</u>:
<font color=DeepPink>BSU </font></TD></TR><TR><TD
width=400><b></TD></TR><tr><td align=center><b>6 - 0</b></td></tr>
<tr><td><img src='Formation7.gif'></img> </td></tr><TR><TD
width=400><b>ZN:<font color=DeepPink>5 </font>ZN WK:<font color=DeepPink>1
</font></TD></TR></table></td></tr><tr></tr></table>
 
M

Mark Dykun

Tom,

This is clearly not the case. Because you are working with the local html
it needs to know where the image resided based on a correctly formatted URL.
To test this create a new C# winforms app, drop the webbrowser control and a
button on the form. Put a bitmap image in the c directory, I created on with
paint .net and called it file1.bmp. In the button click event add the
following code (make sure to change to the filename of your image), run and
press the button. The image will be displayed successfully in the browser
control.

webBrowser1.DocumentText = "<HTML><HEAD></HEAD><BODY><IMG
SRC='file://c:/file1.bmp' /></BODY></HTML>";

if your images are stored relative to the executing assembly you can create
the path based on that as append it onto your filenames ensuring that it can
file the file correctly.

I hope that this helps,

Mark
 
T

Tom

Thanks Mark...that helped. It was the way we were indicating the path. The
bitmap files still do not render but that's OK.
 
R

Registered User

The axWebBrowser will not render either the bmp or the jpg files. IE 7 will
render the jpg file but not the bmp files. I've even tried converting the
bitmaps to GIF files and it's the same - IE7 OK, axWebBrowser - Not OK.

Here's more...the HTML being sent to the axWebBrowser is a simple table
(below). Our first take on this was to generate an HTML file saved to disk
and launch IE. This will now work for us as we've learned that if we change
our file type to jpg or gif IE is cool with that. When we tried to embed
this report into the app we found that none of the file types display. When
we run the app and right click on the browser control and do a view source,
what displays in notepad is <HTML></HTML>...I don't get that...

Here's the code that loads the browser control (axWeb06):
OK I see what the problem is. The html is being written to the
document after the document has been loaded. This means the image
controls never get loaded.

I'm not going to look it up but if the axWebBrowser.Document property
can be assigned to, the document's onload event will probably be
fired. If this is the case build your document dynamically and make
the assignment.

regards
A.G.
 

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

Top