I want to preload an image to prevent screen flashing… Every second the URL is different.
I have tried this, but i can’t see anything in my ASP:Image control…
public void loadImage(string url)
{
pictureBox3.ImageUrl = url;
Thread.Sleep(200);
pictureBox2 = pictureBox3.;
}
Does anyone know how to fix this?
When you use
Thread.Sleep, you’re halting what’s happening on the server; that has a consequence on the client, but only of delaying yet some more and then still incurring the cost of the image download in presence of the user (though it might not always be noticeable).To do this, look into using some client-side script to issue AJAX requests as necessary, these calls can go on asynchronously in the background while the user is viewing the web page, and, so long as the request is always ahead of the change (which you should make it so, by making the change occur only when an image request has completed), you can update the image by doing the replace (by updating the client markup, the
srcof the image, rather than server-side changes).