1

I am creating images grid in asp.net and I am using the following library Justified Gallery . I am using asp:Repeater for the same and its working fine. but when any image path from the grid is not found then full grid is not displaying. my code is

<div id="justifiedGallery">    
<asp:Repeater ID="DataListSearchResult"
                runat="server">
                <ItemTemplate>
                    <div>
                        <a href="javascript:ImageDetailWindowNew('<%#Eval("ItemId")%>')">
                            <img id="img1" style="opacity: 1; filter: alpha(opacity=100);" onerror="imgError(this);" src="/IMAGES/<%#Eval("ImageFile")%>" />
                        </a>
                        <div class="caption">
                            <%#gettitlethumb(Eval("ImageTag"))%>
                        </div>                </div>
                </ItemTemplate>
            </asp:Repeater>
 </div>

I am using a Javascript function to handle this but its not working.

 <script>
    function imgError(image) {
    image.onerror = "";
    image.src = "/images/onerror.gif";
    return true;
    }
</script>

Take a look on this Fiddle. In this fiddle I am using 3 images but the 2nd image path is incorrect and only two images are displaying.I don't want to hide the Not displaying image.

Please help me to create this. Thanks

Gitz
  • 810
  • 1
  • 17
  • 48
  • are you getting any error ? – Nad Dec 29 '15 at 06:27
  • @coder no not getting any error but the `Not found path images` visibility is getting hide – Gitz Dec 29 '15 at 06:32
  • What is onError and whu u pass there empty string ? – vivid Dec 29 '15 at 07:12
  • @vivid I am not getting any error ...i just want to display a `not found` image on the images which is not not exist into the directory. but in Justified Gallery visibility of the images which are not exist into the directory getting hide. – Gitz Dec 29 '15 at 07:16
  • In ur code u pass image.onerror = "" isnt that place where u should pass error handler ? Not sure – vivid Dec 29 '15 at 07:18
  • @vivid error handler like ?? – Gitz Dec 29 '15 at 07:21
  • @vivid I am using this answer for that http://stackoverflow.com/a/92819/4003331 – Gitz Dec 29 '15 at 07:26
  • ye it should do the trick :) tou could probably write image.onerror = ()=>{image.src = "/images/onerror.gif";} – vivid Dec 29 '15 at 07:33

0 Answers0