Dynamic Image from Database

Discussion in 'ASP .Net Web Controls' started by Joe Reiss, May 8, 2006.

  1. Joe Reiss

    Joe Reiss Guest

    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
    Joe Reiss, May 8, 2006
    #1
    1. Advertising

  2. Joe Reiss

    Brock Allen Guest

    This might help:

    http://staff.develop.com/ballen/blog/PermaLink.aspx?guid=2d8b430b-8361-416d-9df8-9aff48bf2481

    -Brock
    http://staff.develop.com/ballen


    > 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
    Brock Allen, May 11, 2006
    #2
    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. Replies:
    1
    Views:
    1,249
    Metalore
    Oct 18, 2006
  2. Laszlo Zsolt Nagy
    Replies:
    1
    Views:
    1,248
    Kartic
    Jan 26, 2005
  3. Waverider
    Replies:
    1
    Views:
    187
    JuanDG
    Sep 21, 2004
  4. Joe Reiss

    Dynamic Image from Database (Post 2)

    Joe Reiss, May 11, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    152
    Joe Reiss
    May 11, 2006
  5. Replies:
    1
    Views:
    213
Loading...

Share This Page