如何在asp.net中按钮点击事件一个接一个地显示图像 [英] how to display image faster, one by one on button click event in asp.net

查看:81
本文介绍了如何在asp.net中按钮点击事件一个接一个地显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在按钮点击事件的图像控制中显示图像。但图像加载速度非常慢。你有什么想法快速显示图像。在asp.net C#

i am showing image in image control on button click event. but image is loading very slowly. do you have any idea for display image very fastly. in asp.net C#

推荐答案

使用JavaScript在客户端使用类似的功能预加载图像:



Pre-load the images using a JavaScript using a function similar to this on the client side:

function preloadImage(url)
{
    var img=new Image();
    img.src=url;
}

document.onload = function() {
    preloadImage("images/image1.jpg");
    preloadImage("images/image2.jpg");
    preloadImage("images/image3.jpg");
    preloadImage("images/image4.jpg");
}





这将缓存客户端上的图像,等待您的事件引用它们。



为了更有效,您可能希望修改JavaScript以异步加载图像:)



This will cache the images on the client already, just waiting for your event to reference them.

To be more effective, you might want to modify the JavaScript to load the images asynchronously :)


这篇关于如何在asp.net中按钮点击事件一个接一个地显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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