Auto Expand Images

Discussion in 'ASP .Net' started by MikeB, Aug 12, 2007.

  1. MikeB

    MikeB Guest

    I currently use the below code to display images from my database. Part of
    what my site allows is for users to click on an image and I open up my
    handler.ashx to display the image. Is there a way to make the image always
    be displayed in full size? Users of my site dont realize that you can
    either click the image to make it go full size or click the icon in the
    lower right part of the image when you mouse over it to expand it.

    TIA
    public class Handler : IHttpHandler {

    public bool IsReusable {

    get {

    return true;

    }

    }


    public void ProcessRequest (HttpContext context) {

    // Set up the response settings

    context.Response.ContentType = "image/jpeg";

    context.Response.Cache.SetCacheability(HttpCacheability.Public);

    context.Response.BufferOutput = false;

    // Setup the Size Parameter

    // Setup the PhotoID Parameter

    Int32 id = -1;

    Stream stream = null;

    string originalsize = "O";

    if(context.Request.QueryString["Size"] != null &&
    context.Request.QueryString["Size"] != "")

    {

    originalsize = context.Request.QueryString["Size"];

    }


    if (context.Request.QueryString["PhotoID"] != null &&
    context.Request.QueryString["PhotoID"] != "")

    {

    id = Convert.ToInt32(context.Request.QueryString["PhotoID"]);

    stream = PhotosService.GetPhoto(id, originalsize);

    }

    else

    {

    id = Convert.ToInt32(context.Request.QueryString["ProductID"]);

    stream = PhotosService.GetFirstPhoto(id,
    Convert.ToInt32(context.Request.QueryString["CompanyID"]), originalsize);

    }

    // Get the photo from the database, if nothing is returned, get the default
    "placeholder" photo

    if (stream == null)

    {

    stream = new
    FileStream(HttpContext.Current.Server.MapPath("~/Images/placeholder-200.jpg"),
    FileMode.Open, FileAccess.Read, FileShare.Read);

    }

    // Write image stream to the response stream

    const int buffersize = 1024 * 16;

    byte[] buffer = new byte[buffersize];

    int count = stream.Read(buffer, 0, buffersize);

    while (count > 0)

    {

    context.Response.OutputStream.Write(buffer, 0, count);

    count = stream.Read(buffer, 0, buffersize);

    }


    }

    }
    MikeB, Aug 12, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anders
    Replies:
    0
    Views:
    851
    Anders
    Apr 27, 2006
  2. Allan Valeriano

    Auto scroll when a JTree's node expand

    Allan Valeriano, Jul 10, 2007, in forum: Java
    Replies:
    2
    Views:
    2,252
    joel augustine
    May 12, 2012
  3. linkswanted
    Replies:
    1
    Views:
    886
  4. Tony WONG

    Disable textbox auto expand

    Tony WONG, May 7, 2010, in forum: ASP .Net
    Replies:
    2
    Views:
    642
    Tony WONG
    May 7, 2010
  5. Jerry C

    auto expand for text in a web page

    Jerry C, Jun 20, 2008, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    206
    Steven Cheng [MSFT]
    Jun 25, 2008
Loading...

Share This Page