This is a code taken from this form which was given to be as an solution for my problem
i worked for hrs but not able to rectify the same. and my previous question was closed/marked as answer
My problem is there is a query string link web page in my asp.net+vb code web. When a visitor clicks in a link button the data pertaining to that person is diplayed i am willing to display the photo of the person in that page
Code from this forum
.vb
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Request.QueryString("PNO") IsNot Nothing Then
Try
' Read the file and convert it to Byte Array
Dim filePath As String = "C:\AWING\PHOTOS\"
Dim filename As String = Request.QueryString("PNO")
Dim contenttype As String = "image/" & Path.GetExtension(filename).Replace(".", "")
Dim fs As FileStream = New FileStream(filePath & filename, FileMode.Open, FileAccess.Read)
Dim br As BinaryReader = New BinaryReader(fs)
Dim bytes As Byte() = br.ReadBytes(Convert.ToInt32(fs.Length))
br.Close()
fs.Close()
'Write the file to Reponse
Response.Buffer = True
Response.Charset = ""
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.ContentType = contenttype
Response.AddHeader("content-disposition", "attachment;filename=" & filename)
Response.BinaryWrite(bytes)
Response.Flush()
Response.End()
Catch
End Try
End If
End Sub
.aspx
<asp:image ToolTip = "ASP Image Control" ID="Image2" runat="server" ImageUrl ="pers.aspx?FileName=TestJPG.jpg" Height="156px" Width="174px"></asp:image>
The code above is displying images which are placed in C:\images folder correctly. but my problem is to disply the image of a perticular person whose pers number (PNO) is used as link for query string
The code below was done by me and the image was not diplayed
Dim PNO As String
'PNO = Request.QueryString("PNO")
'Image1.ImageUrl = "~/images/" + PNO + ".jpg"
'End Sub