How to display multiple images in one browser window?

G

Guest

Can I use WriteFile methods? It seems that it does not work.
For example, the following code only dispay one figure.
Response.WriteFile("images/image002.jpg")
Response.Write("<br><p>")
Response.WriteFile("images/image003.jpg")
Response.Write("<br><p>")

Any help?

Thanks

David
 
B

Brock Allen

<img> tags require an independant request tot he server for the JPG data,
so you can't interlace JPG and HTML data in the response back to the browser.
You'll have to setup a secondary page or IHttpHandler to serve those up.
Or just set the <img src="images/foo.fpg"> path and let the normal webserver
serve up those static files.
 
G

Guest

Is it the static way for displaying images? Can i dynamically display .jpg
files in this way? For example, I convert images into .jpg format and display
them on the web page in runtime on request.

David
 
C

Craig Deelsnyder

Is it the static way for displaying images? Can i dynamically display
.jpg
files in this way? For example, I convert images into .jpg format and
display
them on the web page in runtime on request.

David

You want to create an aspx to handle displaying an image, have it do the
WriteFile() using a QueryString argument passed in.

Let's call this page foo.aspx and the querystring arg is imageUrl. Then
in my main page (where I want to show the image) I would do

<img src="foo.aspx?imageUrl=images%2Fimage002.jpg" >...
<img src="foo.aspx?imageUrl=iamges%2Fimage003.jpg" >...

note I URL encoded the / to %2F. Now in foo.aspx, you want to remove all
code, whitespace, html, everything from the .aspx file; then in the
..aspx.vb or .aspx.cs do all the work of displaying the image via
WriteFile() (write the file with url = imageUrl). You can also Google
around a little bit for a thorough example, you'll want to set the
content-type to the image type you are using in foo.aspx as well as some
miscellaneous response settings.

Why remove everything from .aspx? You can only have 1 MIME type per
response. Previously (as pointed out the other poster) you had
intermingled image and html data. Doesn't work. And if anything is in
your .aspx (other than directives), it will be compiled as a Literal
(HTML) and spit out with the response, once again mixing MIME types
inadvertently.
 
G

Guest

Thank you, Craig.

I will try this way.

David

Craig Deelsnyder said:
You want to create an aspx to handle displaying an image, have it do the
WriteFile() using a QueryString argument passed in.

Let's call this page foo.aspx and the querystring arg is imageUrl. Then
in my main page (where I want to show the image) I would do

<img src="foo.aspx?imageUrl=images%2Fimage002.jpg" >...
<img src="foo.aspx?imageUrl=iamges%2Fimage003.jpg" >...

note I URL encoded the / to %2F. Now in foo.aspx, you want to remove all
code, whitespace, html, everything from the .aspx file; then in the
..aspx.vb or .aspx.cs do all the work of displaying the image via
WriteFile() (write the file with url = imageUrl). You can also Google
around a little bit for a thorough example, you'll want to set the
content-type to the image type you are using in foo.aspx as well as some
miscellaneous response settings.

Why remove everything from .aspx? You can only have 1 MIME type per
response. Previously (as pointed out the other poster) you had
intermingled image and html data. Doesn't work. And if anything is in
your .aspx (other than directives), it will be compiled as a Literal
(HTML) and spit out with the response, once again mixing MIME types
inadvertently.
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top