Last post Jan 22, 2016 07:02 AM by oned_gk
Jan 22, 2016 06:44 AM|lolo512|LINK
I want to display images in my homepage.so I retrieve the path from the database but seems that some of the images doesn't exist in the selected folder.
I want to display a default image if the image doesn't exist in the folder(default.jpg)
but how can I check if the image really exist in the folder. I was thinking of checking if the image has content or not but I can't find a sample code for checking image content.
here is my current code
<div class="image col-3" runat="server" visible='<%#IIf(Eval("Image") Is DBNull.Value, False, True) %>'>
<img src="<%# Eval("Image")%>" />
I want instead of Is DBNull.value to check for the content value if null then don't display.
anyone can help please and thank you
Jan 22, 2016 06:54 AM|Lokesh B R|LINK
ONERROR add the default image path
<img src="<%# Eval("Image")%>" onerror="this.src='~/images/defaultimage.jpg'" />
Jan 22, 2016 07:02 AM|oned_gk|LINK
Lokesh is right, but maybe will not work with "~/" address
Try like this