trying to display an image from database in an image control... third day...no luck so far...
Displaybutton on Employee.aspx
Protected Sub DisplayButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles DisplayButton.Click
bind()
GridView1.Visible = "True"
If EmployeeIDTextBox.Text = "" Then
MsgBox("Please enter EmployeeID!")
Else
Image1.ImageUrl = "~/HttpHandler.ashx?EmployeeID=" & EmployeeIDTextBox.Text
End If
End Sub
This is the handler:
Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
'context.Response.ContentType = "text/plain"
'context.Response.Write("Hello World!")
Dim EmployeeID As Integer
If (Not (context.Request.QueryString("EmployeeID")) Is Nothing) Then
EmployeeID = Convert.ToInt32(context.Request.QueryString("EmployeeID"))
Else
Throw New ArgumentException("No parameter specified")
End If
Dim imageData() As Byte = {}
' get the image data from the database using the employeeId Querystring
context.Response.ContentType = "image/jpeg"
' You can retrieve this also from the database
context.Response.BinaryWrite(imageData)
End Sub
this is the image control (on Employee.aspx) in which i wanna display the image
<asp:Image ID="Image1" runat="server" imageUrl="HttpHandler.ashx?EmployeeID=7" />
got a lotta help... seems wasnt enough...