I have a click event which is supposed to delete an image. I have a dropdown which displays all the images in a folder. When I try and use the dropdown selected value, the image is not deleted. However, if I pass the name of an image, the image is deleted. In the code below, when I hard code the image name ( commented out below ) the code works, but when I use the dropdown value it doesn't.
Any ideas?
mike
Any ideas?
mike
Code:
Protected Sub godeleteimage_Click(ByVal sender As Object, ByVal e As EventArgs) Handles godeleteimage.Click
If deleteimage.Checked = True Then
'Dim ImageName = "test1thumb.png"
Dim ImageName = imagemanagerdropdown.SelectedValue.ToString
Dim ImagePath As [String] = [String].Format("{0}\{1}", Server.MapPath("gallery"), ImageName)
If System.IO.File.Exists(ImagePath) Then
System.IO.File.Delete(ImagePath)
End If
End If
UpdatePanelImageManager.Update()
End Sub