how to apply the load on demand (Lazy loading) concept in datalist for Images using asp.net?

前端 未结 3 1689
孤街浪徒
孤街浪徒 2020-12-18 16:23

In my asp.net application have one data list, page load event I have to bind number of image items(1000), how to apply the load on demand (What you can say Lazy loading of i

相关标签:
3条回答
  • 2020-12-18 16:40

    Well you can do this using jQuery's lazy image load tool... This is great and just fit your needs.

    http://www.appelsiini.net/projects/lazyload

    Lazy Load is a jQuery plugin written in JavaScript. It delays loading of images in long web pages. Images outside of viewport (visible part of web page) wont be loaded before user scrolls to them. This is opposite of image preloading.

    Using Lazy Load on long web pages containing many large images makes the page load faster. Browser will be in ready state after loading visible images. In some cases it can also help to reduce server load. (Above is taken from the site)

    For demo pls visit this page and you would know that this is the thing you are looking for.

    This is an easy to integrate stuff so fit your needs.

    To make it in Datalist or repeater you can do this using

    <asp:Image ID="LazyImages" runat="server" 
      CssClass="lazy" src="img/BlankImage.gif" data-original="<%# Eval("URLofImageFromDB"))%>" />
    

    You need to concentrate on CssClass and SRC attribute while binding and rest is taken care by jQuery.

    Configuration of JQuery is important.

    0 讨论(0)
  • 2020-12-18 16:54

    The DataList is not meant for this purpose. You are better off using javascript and ajax calls.

    Have a url that takes the StartIndex and Count of as parameters and list our the urls to show. Then just append them in using javascript.

    0 讨论(0)
  • 2020-12-18 16:57

    There is not any built in function in asp.net to do this task.But you may use jquery plugin for this purpose.

    Lazy loader delays loading of images in (long) pages. Images below the fold (far down in the page) wont be loaded before user scrolls down.

    For details see a link. http://archive.plugins.jquery.com/project/lazyload

    0 讨论(0)
提交回复
热议问题