G
Guest
Hi,
I'm struggling to display an image on asp.net webform (vb.net). The image is
stored in a image field in a sql server database.
I have read a good few solutions to it and still havnt got it working for
the last 2 days.
Heres my code...
when a user clicks on "View Image" button in a datagrid the following code
executes which just passes the EmployeeID to the webform which displays the
photo of the employee.
Response.Write("<script language = ""Javascript"">var
win=window.open('empphoto.aspx?sid=" & E.Item.Cells(5).Text &
"',null,'width=510,height=355,top=250,left=250','true');</script>")
The empphoto webform has just this in its html..
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Image Width="150" Height="125" ImageUrl='photo.aspx' Runat=server
ID="Image1"/> </form></body>
The photo webform has a page load event of...
Dim sidVar As Integer
sidVar = Request.QueryString("Sid")
Dim dr As SqlDataReader
dr = SQLDAL.SQLDAL.ExecuteDataReader(ConnStr, "HR_GetPhoto")
If dr.Read() Then
Response.Clear()
Response.ContentType = "image/jpeg"
Response.OutputStream.Write(CType(dr("photo"), _
Byte()), 0, CInt(10000))
Response.AddHeader("Content-Disposition", _
"inline;filename=" + dr("photo").ToString())
End If
Its really this last piece of code that I think is the problem. Can anyone
help? Either point me in the direction of some code that does work or can you
see whats wrong in my code? All I get is the horrible red x image.
Thanks
N
I'm struggling to display an image on asp.net webform (vb.net). The image is
stored in a image field in a sql server database.
I have read a good few solutions to it and still havnt got it working for
the last 2 days.
Heres my code...
when a user clicks on "View Image" button in a datagrid the following code
executes which just passes the EmployeeID to the webform which displays the
photo of the employee.
Response.Write("<script language = ""Javascript"">var
win=window.open('empphoto.aspx?sid=" & E.Item.Cells(5).Text &
"',null,'width=510,height=355,top=250,left=250','true');</script>")
The empphoto webform has just this in its html..
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Image Width="150" Height="125" ImageUrl='photo.aspx' Runat=server
ID="Image1"/> </form></body>
The photo webform has a page load event of...
Dim sidVar As Integer
sidVar = Request.QueryString("Sid")
Dim dr As SqlDataReader
dr = SQLDAL.SQLDAL.ExecuteDataReader(ConnStr, "HR_GetPhoto")
If dr.Read() Then
Response.Clear()
Response.ContentType = "image/jpeg"
Response.OutputStream.Write(CType(dr("photo"), _
Byte()), 0, CInt(10000))
Response.AddHeader("Content-Disposition", _
"inline;filename=" + dr("photo").ToString())
End If
Its really this last piece of code that I think is the problem. Can anyone
help? Either point me in the direction of some code that does work or can you
see whats wrong in my code? All I get is the horrible red x image.
Thanks
N