display [no image found] when image src returns no image

I generate my image src from databse field called [pictureName]. I want when Picture name is null or the name doesn't return image to display [image not found] picture. 
Here is my aspx code to generate img:

<img src="WEBIMAGES/<%#Eval("BrandName")%>/<%# Eval("PictureName") %>" alt="" title="<%# Eval("ProductName") %>">

my images divided into folders for each brand. i have noImage.jpg in every folder. 
how to display this image when no image displayed. 
I'm using asp.net webforms 
I tried to use onerror event, but not working. 

Thanks in advance

Last updated:1/16/2015 11:01:09 PM

1 Answers

Anonymous User
Anonymous User

You could use a coalesce on the picture name as follows:

<img src='WEBIMAGES/<%#Eval('BrandName')%>/<%# Eval('PictureName') ?? 'noImage.jpg' %>' alt='' title='<%# Eval('ProductName') %>'>