I have the following function:
Public Shared Function imageExists(ByVal path As Object) As Boolean
If IsDBNull(path) = False Or Not path Is Nothing Then
Dim pathString As String = Convert.ToString(path)
If Exists(HttpContext.Current.Server.MapPath(path)) Then
Return True
Else
Return False
End If
Else
Return False
End If
End Function
Called by the visible property for this image control:
<asp:Image ID="img_SmallImage" runat="server" ImageUrl='<%# "~/Content/Images/Exclusive/" + Eval("trip_SmallImage") %>' Visible='<%# OnTheMain.Images.Validation.imageExists(Eval("trip_SmallImage"))%>' />
No matter what I try for the If IsDBNull
part, it either ignores it and executes the code, or returns an error such as Conversion from type 'DBNull' to type 'String' is not valid.
How can I rectify the situation?