VB.NET / ASP.NET - picImage.visible = true only if the image is in directory.

admin

Administrator
Staff member
OK, this might be hard to explain. Creating a web app using VB.NET and ASP.NET. A user wants me to design a page which would have 3 images. These images would change about once a month. The problem is sometimes he'll only have 2 images, sometimes 1, sometimes all 3. In a typical page, if the image is missing from the directory, a box with a red X appears where the image on the webpage would be. I'm looking for a way to code this so that that box with red X never appears. I want to give the user the option to have 1,2 or 3 images. So what needs to happen is if "c:\images\image3" exists then put it on the page, but if a file by that name doesn't exist, do not even make the red X place holder visible. If c:\images\image3 exists, then
picImage3.visible = true
else
picImage3.visible = false.

this isn't my code (I don't have any for this), but it hopefully gives you an idea of what I'm looking to do.

I'm obviously missing the most important part. Help would be greatly appreciated! thankstry this.

first... Imports system.io
Dim strPicPath As String = "C:\images\colors.gif"
Dim objLeftFile As FileInfo = New FileInfo(strPicPath)

If objLeftFile.Exists Then
Me.picImage.Visible = True
End If
 
Back
Top