views:

42

answers:

1

There is a web site page which is coded on asp.net with using c# and ajax is enabled too.

I want a very fast loading web page; which is going to happen with the following architecture;

1- First all data is shown by the text boxes (There are 50 text boxes, it is an application form.)

2- When the web Page is requested and loaded, then I want all the photos are shown near the each text boxes 10 by 10 from top of the page till the end of it. (Each photo is between 5 kb - 20 kb; )

I know ImageHandler's the question is how can I put all these idea into real life? some examples and ideas will be great ! thanks

bk

+1  A: 
(function(images, elements) {
    var fetchImages = function() {
        if(images.length > 0) {
            var numImages = 10;
            while(images.length > 0 && numImages-- > 0) {
                // assuming your elements are <img>
                document.getElementById(elements.shift()).src = images.shift();
                // if not you could also set the background (or backgroundImage) css property
                // document.getElementById(elements.shift()).style.background = "url(" + images.shift() + ")";
            }
            setTimeout(fetchImages, 5000);
        }
    }

    // bind to window onload
    window.onload = fetchImages;
    // if you're going to use something like jquery then do something like this instead
    //$(fetchImages);
}(['url1', 'url2', 'url3'], ['img1', 'img2', 'img3']))

Something like that would do what, I think, you're asking.
The last line would probably be replaced with something like

}(<%=ImageUrls %>, <%=ImageElements %>))
Justin
Hi Sir, Thanks for your detailed answer. The very last question is how can I implement that JavaScript above to my asp.net file since I want the client feel that everything is fine and loaded immediately except for those images that are going to be loaded every 10 seconds. I am planing the put a loading.gif, for those remaining ones' default source value. regards
blgnklc
I updated my above snippet to load 10 images at a time in 5 second intervals. I also added the call to have it called when the page is loaded (the window.onload line or the commented out $(fetchImages)If you want a loading gif then simply assign the loading image to all of the elements initially and the above code will overwrite them after the page has loaded in the 5 second increments.
Justin
@Justin could you please have a look to the second question above in the page of the following link, http://stackoverflow.com/questions/2919303/page-clientscript-register-a-pair-of-javascript-code
blgnklc