如何申请点播(延迟加载)的概念中的负载数据列表使用asp.net图片? [英] how to apply the load on demand (Lazy loading) concept in datalist for Images using asp.net?

查看:96
本文介绍了如何申请点播(延迟加载)的概念中的负载数据列表使用asp.net图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的asp.net应用程序有一个数据表,页面加载事件我有绑定(1000)图像的项目数量,如何应用需求负载(你可以说图像延迟加载什么)(滚动时页面当时只有绑定Facebook等新的需求页的项目)

基本上我不想页面加载延迟,由于没有图像和加载时间。
我的code是
页面加载事件
获取数据并绑定在DataList

 的SqlCommand COMD =新的SqlCommand(usp_GetSubCategoryProducts,OBCON);
                comd.CommandType = CommandType.StoredProcedure;
                comd.Parameters.Add(@ ID,SqlDbType.Int).value的= SubCategory_id;                DataSet的DS =新的DataSet();
                SqlDataAdapter的sqlAdapter =新的SqlDataAdapter();
                sqlAdapter.SelectCommand = COMD;
                sqlAdapter.Fill(DS);
 listView.DataSource = DS;
                listView.DataBind();


解决方案

那么你可以做到这一点使用jQuery的懒图像加载的工具...这是伟大的,只是满足您的需求。

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

延迟加载是用JavaScript编写的一个jQuery插件。它的图像延迟加载在长网页。 视窗(网页的可见部分)以外的图像用户滚动到它们之前不会被加载。这是图像preloading相反

在包含许多大型图像长网页应用延迟加载,使网页加载速度更快。浏览器将处于就绪状态装载可见光图像后。在某些情况下,它也能帮助减少服务器的负载。 (以上是从现场拍摄)

有关演示请访问这个页面,你就会知道,这是事情你所寻找的。

这是一个易于集成的东西,所以满足您的需求。

要使它在DataList或Repeater可通过使用做

 < ASP:图片ID =LazyImages=服务器
  的CssClass =懒SRC =IMG / BlankImage.gif数据原=<%#的eval(URLofImageFromDB))%GT; />

您需要集中精力的CssClass和SRC属性,同时具有约束力,其余由jQuery的照顾。

JQuery的配置是非常重要的。

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 images) (when scrolling the page that time only bind the items like facebook new needs page)

Basically I don't want page load delay due to no of images and their loading time. my code is page load event get the data and bind the datalist

SqlCommand comd = new SqlCommand("usp_GetSubCategoryProducts", OBcon);
                comd.CommandType = CommandType.StoredProcedure;
                comd.Parameters.Add("@ID", SqlDbType.Int).Value = SubCategory_id;

                DataSet ds = new DataSet();
                SqlDataAdapter sqlAdapter = new SqlDataAdapter();
                sqlAdapter.SelectCommand = comd;
                sqlAdapter.Fill(ds);
 listView.DataSource = ds;
                listView.DataBind();

解决方案

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.

这篇关于如何申请点播(延迟加载)的概念中的负载数据列表使用asp.net图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆