Advice needed: reading image (binary) data from a db, to be placed in an Image control ??

Discussion in 'ASP .Net' started by Denise Smith, Nov 20, 2003.

  1. Denise Smith

    Denise Smith Guest

    Hello,

    I'm wondering if anyone can help me out here?

    I want to be able to browse records in a database where one of the
    fields contains an image.

    I think I might have to extract the image to a byte array, write it to
    a temp file then refer to the temp file as the URL source for the
    Image control.

    I've been trying this method, but I'm stuck on a couple of points.

    1. The ImageURL property is not being written to the page when it gets
    to the browser, and

    2. I'm having trouble writing the byte array to a file on disk.

    Am I going about this the wrong way?


    -Denise
     
    Denise Smith, Nov 20, 2003
    #1
    1. Advertising

  2. You don't need to write a byte array or anything else to a disk. Just create
    an ASPX page that grabs the binary data, converts it to an in-memory Bitmap,
    sets the Response.ContentType property to "image/jpg" and streams the image
    to the client in the Response.OutputStream. Then the URL of this ASPX page
    can be the source of an HTML Image tag, as in:

    <img src="image.aspx">

    --
    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    Big things are made up
    of lots of little things.

    "Denise Smith" <> wrote in message
    news:...
    >
    > Hello,
    >
    > I'm wondering if anyone can help me out here?
    >
    > I want to be able to browse records in a database where one of the
    > fields contains an image.
    >
    > I think I might have to extract the image to a byte array, write it to
    > a temp file then refer to the temp file as the URL source for the
    > Image control.
    >
    > I've been trying this method, but I'm stuck on a couple of points.
    >
    > 1. The ImageURL property is not being written to the page when it gets
    > to the browser, and
    >
    > 2. I'm having trouble writing the byte array to a file on disk.
    >
    > Am I going about this the wrong way?
    >
    >
    > -Denise
    >
    >
     
    Kevin Spencer, Nov 20, 2003
    #2
    1. Advertising

  3. Denise Smith

    Denise Smith Guest

    Thanks for the help. I got it to work!


    On Thu, 20 Nov 2003 14:33:20 -0500, "Kevin Spencer"
    <> wrote:

    >You don't need to write a byte array or anything else to a disk. Just create
    >an ASPX page that grabs the binary data, converts it to an in-memory Bitmap,
    >sets the Response.ContentType property to "image/jpg" and streams the image
    >to the client in the Response.OutputStream. Then the URL of this ASPX page
    >can be the source of an HTML Image tag, as in:
    >
    ><img src="image.aspx">
     
    Denise Smith, Nov 22, 2003
    #3
    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. okaminer
    Replies:
    2
    Views:
    904
    okaminer
    Feb 8, 2005
  2. Deryck
    Replies:
    4
    Views:
    536
    derek giroulle
    Jun 22, 2004
  3. Replies:
    0
    Views:
    2,081
  4. AAaron123
    Replies:
    3
    Views:
    294
    AAaron123
    Oct 31, 2009
  5. Vijay

    tool tip for dropdown box, placed in data grid control

    Vijay, Aug 31, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    162
    Ken Cox [Microsoft MVP]
    Sep 4, 2006
Loading...

Share This Page