Question : IIF Statement

In my attached code, is there a way to put an IIF statement so that if the photo {0}.jpg doesn't exist that it loads a default image?
1:
2:
3:
<div style="float: left; border: 1px solid #999999; margin-right: 15px; width: 180px;
                            height: 220px; background-position: center; background-repeat: no-repeat; background-image: url('<%# Eval("CustomerID", "Img/Northwind/Customers/{0}.jpg") %>');">
                        </div>

Answer : IIF Statement

Yes, On your code when you eval CustomerId or bind this Will return a value that will be the name of the image, with the Javascript that I send you you can say that if the return is null or blank or the condition that you wnat then return the default image name if not return the value that get the customer photo.I modify the code because I made a mistake. Will be like this

<script language="vbscript" runat="server">
    Function EvalPhoto(ByVal Customer)
        Dim Cid, ReturnImg
        Cid = Customer
     'If The Customer Exist or the condition that you want
      If Cid is dbnull.value Then
            ReturnImg = Cid
        Else
            ReturnImg = "Default Image"
        End If
        Return ReturnImg
    End Function
</script>
Random Solutions  
 
programming4us programming4us