Dynamic Image from Database

J

Joe Reiss

Hi All,

Using vs2005, C#, SQL Server 2005/Shared Environment.

I'm attempting to populate an image control from a jpeg stored in a image
field in sql server. Tried using both HTML image and ASP image - can't get
either to work.

I'm basically using the technique outlined in the ASP.NET 2.0 Cookbook
(OReilly).

So, in my page that has the image controls the code in the view photo button
event is

img.Src = "LoadPhoto.aspx?ID=7";
img.visible = true;

The LoadPhoto.aspx has no HTML just the 'Page, AutoEventWireup,
CodeFile,Inherits' as specified for this technique. The codebehind for
LoadPhoto.aspx.cs has the Page_Load event where it gets the jpeg data and
calls Response.ContentType = "image/jpeg" then Response.BinaryWrite( calls
function that returns byte[] array from database).

I cannot get this to work. Also, I put in some code into LoadPhoto.aspx.cs
to populate a session varible just to see if this Page-Load is firing. The
session variable does not get populated, so, it seems that all this code
doesn't even execute.

Can someone help me out?

Thanks,
Joe
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top