Click here to Skip to main content
15,904,153 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The following code I use to show image in an image control but it can not show image,How can I solve this problem.

Protected Sub UploadButton_Click(sender As Object, e As EventArgs)
If FileUploadControl.HasFile Then
Try
Dim filename As String = Path.GetFileName(FileUploadControl.FileName)
FileUploadControl.SaveAs(Server.MapPath("~/") & filename)
temp = "~/" & filename
StatusLabel.Text = "Upload status: File uploaded!"
Image1.Visible = True
Image1.ImageUrl = temp
Catch ex As Exception
StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message
End Try
End If
End Sub
Posted
Comments
Asim Mahmood 20-Feb-13 1:52am    
Debug your code and check file path, i think issue in your path.
Farzanatayeb 20-Feb-13 2:18am    
How I can find the file path.Please mention it.
Farzanatayeb 20-Feb-13 2:29am    
when I debug it by break point.
value FileUploadControl.hasfile is shown False
and value of FileUploadControl.filename is shown ""

1 solution

hi,

Whatever the code you written seems correct, i didn't checked your code. may be the problem in Path.

ex:

Image1.ImageUrl = @"~/" + YourPath;
 
Share this answer
 
Comments
Farzanatayeb 20-Feb-13 2:30am    
when I debug it by break point.
value FileUploadControl.hasfile is shown False
and value of FileUploadControl.filename is shown ""

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900