1

I wish to create a very simple web app that simply displays an Image(s) from a database based upon either a date (from a calendar click event) or from a keyword search, getting the image(s) is no problem but I don't know how to display the resulting image. Preferably I would like to display the image in a table or grid or whatever, adjacent to the Calendar and TextBox on the same page that I used to get the search critera

So how to I stream an image to a page from a codebehind bitmap variable ?

Edit: The database is a cloud database, so databinding is out.

3 Answers 3

2

Take a look at the DynamicImageHandler for ASP.NET up on the CodePlex ASP.NET Futures site:

http://www.hanselman.com/blog/ASPNETFuturesGeneratingDynamicImagesWithHttpHandlersGetsEasier.aspx

Sign up to request clarification or add additional context in comments.

1 Comment

Scott, perfect. Just what I was looking for. Thanks.
0

If you don't have the physical file on hand, try using:

Response.OutputStream.Write(bitmapbuffer, bitmapbuffer.Length)

I've done this in the past to dynamically serve pdfs and tifs, and it works quite nicely. You'll need to set your img's src attribute to contain the information you need. This web site has an example close to what you are looking for:

http://www.jigar.net/articles/viewhtmlcontent3.aspx

Comments

-1

This isn't a good idea, since you don't know when to release the resource.

Rather, create a page (or a page handler, etc, etc) which will take the parameters you need in the querystring to perform the lookup in the database to get the image.

Then, in the handler, you load your image from the database and then stream the bytes back through the page.

In the original page, you set the src attribute of the img tag to the other page, with the appropriate parameters.

1 Comment

How about sites like "the daily dilbert"? Where they do pretty much exactly what I am trying to achieve.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.