Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display dynamic images using asp.net 2.0 & Lightbox 2

Status
Not open for further replies.

WIREMESH

Programmer
Mar 15, 2004
109
US
In our web app, we can have images associated with each record. When the user selects a specific record, and we display a new page, there is a button on the form to display am image. I would like to use Lightbox 2 to display the image. Has anyone done this?
 
The instructions are only for "static" images. Not images that vary according to what is stored in a database.
 
use a generic handler to render the image.
Code:
<img src="RenderImage.ashx?id=1234" />
Code:
public class RenderImage : IHttpHandler
{
  public bool IsReusable{get{return true;}}

  public void ProcessRequest(HttpContext context)
  {
     var id = int.Parse(context.Request.QueryString["id"]);
     byte[] image = GetImageFromDatabase(id);

     context.Response.BinaryWrite(image);
     context.Response.ContentType = "image/jpg";
  }

  private static byte[] GetImageFromDatabase(int id)
  {
     typical ado.net code.
  }
}

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top