图像需要很长时间才能加载到asp转发器中 [英] Images takes much time to load in asp repeater

查看:51
本文介绍了图像需要很长时间才能加载到asp转发器中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个转发器,我放置< asp:Image>其中



 ImageUrl = ' <%#DataBinder.Eval(Container.DataItem,Path)%>' 





Container.Dataitem中的路径是转发器中显示的图像的URL,URL在选择查询的帮助下生成一个字符串,并通过上传的图像上传



将会有将近140张图片将加载到asp转发器中,加载所有图片需要20秒..但我的要求是将其管理到5到6秒......



除了我观察到一些解决方案,你可以使用AJAX一次加载一个。然后,您可以控制它们的加载顺序(例如,首先加载前10个,然后加载下10个)。类似于Facebook上传照片的方式。但是我如何使用它......?是指我使用哪种扩展器



你们有没有解决方案

解决方案

如果是物理图像你可以检查图像权重,如果图像太重,你可以用Photoshop编辑它并选择保存图像为web选项


所有代码都会生成HTML,然后发送回浏览器。图像对象的ImageUrl中的URL只是图像标记的src属性。

< img src =imageUrl/> 



所以你必须在3个视图中查看这个



1.生成HTML或运行程序需要多长时间。

2.发送回浏览器的HTML块有多大

3.浏览器填充图像URL以完成页面请求需要多长时间。





1.如果生成代码需要很长时间,则必须优化代码才能更快地运行。 />


2.如果发送回浏览器的HTML太大,并且需要很长时间,则必须编写更高效或紧凑的HTML以减小大小。



3.如果浏览器需要永久下载每个图像,那么你需要使文件尺寸更小。



3A。要缩小图像文件大小,请使用JPEG格式压缩图像,然后选择较低的质量,或缩小图像尺寸。如果你在24岁时使用PNG,那么图像的文件大小会很大。



3B。你也可以在HTML中显示更少的图像,比方说每页10个,并构建一个索引系统来获取当前页面并将其分成10页。



3C。有时这是感知问题。您可以更改界面的显示以使其更具交互性,您可以在其中显示图像的缩略图,并且必须单击以查看大版本。并不是每个人都想看到每一张图片,所以他们可以选择。



最后



这叫做lazyload,一个J Query插件,它将使用浏览器窗口位置来确定何时下载图像。因此,当窗口区域变得可见时,图像会下载。



就个人而言,它只是来自GUI和程序设计的经验,您可以在其中创建满足用户的程序感知速度。


您可以参考以下链接并使用相同的方法。



http://aspsnippets.com/Articles/Load-data-while-Scrolling -Page-down-with-jQuery-AJAX-and-ASPNet.aspx [ ^ ]



希望这能帮到你..

I have a repeater in which I place <asp:Image> in which

ImageUrl='<%# DataBinder.Eval(Container.DataItem, "Path") %>'



Path in the Container.Dataitem is the URL of the images which shown in repeater and URL makes a string with the help of select query and images uploaded bynamically

There will be almost 140 images which will be load in asp repeater and it takes 20 second to load all images ..but my requirement is to manage it to 5 to 6 seconds...

As well as i observed some solution like you could use AJAX to load them one at a time. You can then control the order in which they are loaded (eg load top 10 first, then load next 10). Similar to how Facebook does photo uploads. But how i use it...? means which extender i use

Do you guys have any solution

解决方案

if is physical image you can check image weight, if the image is too heavy you can edit it with Photoshop and choose the option "save image for web"


All your code does is generates HTML that is sent back to the browser. The URL in ImageUrl of the image object is just the src attribute of the image tag.

<img src="imageUrl" />


So you have to look at this in 3 views

1. How long does it take to generate the HTML or run the program.
2. How large is the HTML block that is being sent back to the browser
3. How long does the browser take to populate the image url's to complete the page request.


1. If it takes a long time to generate the code, you have to optimize the code to run faster.

2. If the HTML being sent back to the browser is too large, and takes a long time, you have to write more efficient or compact HTML to reduce the size.

3. If the browser takes forever to download each image, then you need to make the images smaller in file size.

3A. To reduce the image file size, you compress the image using the JPEG format, and select a lower quality, or make the image size smaller. If your using PNG at 24, then the images will be huge in file size.

3B. You can also show less images in the HTML, let's say 10 per page, and build an index system to take the current page and chop it up into 10 pages.

3C. Sometimes it's a matter of perception. You change the display of your interface to make it more interactive, in which you show a thumbnail of the image, and you have to click to see the large version. Not everybody wants to see every image, so they can choose.

Finally

It's called lazyload, a J Query plugin, that will use the browsers window position, to determine when to download the images. So when the windows area becomes visible, the image downloads.

Personally, it's just comes from experience in GUI and program designs, in which you create programs that satisfy the users perception of speed.


You can refer the below link and use the same approach .

http://aspsnippets.com/Articles/Load-data-while-Scrolling-Page-down-with-jQuery-AJAX-and-ASPNet.aspx[^]

Hope this helps you...


这篇关于图像需要很长时间才能加载到asp转发器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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