I have to preload 1000 png format photo to the ascx file, its not logic to write every png name alone, so i am looking for a dynamic preloader, any helps?Thank you
You will however need to build the array as images are added in your .ascx file which depending on how you are doing so can be accomplished in your code and passed as a Literal or ViewBag variable to the JavaScript.
You will have to tell the javascript all of the images, it can't scan the server to determine them. Also, that number of images loaded into the client may cause issues because that's a lot of memory you are attempting to use on the client's computer and
may result in their browser crashing. If it's a mobile browser on a cellular connect, you could eat up a large chunk of their bandwidth with the pre-loader. It also has the potential for not allowing the browser itself to properly cache the images as it normally
does.
Don't forget to mark useful responses as Answer if they helped you towards a solution.
Marked as answer by khayalian on Jan 10, 2013 01:55 PM
If you are pulling the images dynamically you can add them at that time to a string you can build to use as an array which you can pass to your JavaScript using a Literal or viewbag variable.
Marked as answer by khayalian on Jan 10, 2013 01:55 PM
khayalian
Member
127 Points
143 Posts
Preloader
Jan 09, 2013 12:26 PM|LINK
hello
I have to preload 1000 png format photo to the ascx file, its not logic to write every png name alone, so i am looking for a dynamic preloader, any helps?Thank you
prasad.magan...
Member
681 Points
214 Posts
Re: Preloader
Jan 09, 2013 12:34 PM|LINK
load all png files i.e. *.png in ascx file
Prasad Maganti
khayalian
Member
127 Points
143 Posts
Re: Preloader
Jan 09, 2013 12:41 PM|LINK
How i can load all png files in ascx? this is my question
jprochazka
Contributor
4846 Points
740 Posts
Re: Preloader
Jan 09, 2013 01:05 PM|LINK
You can load all your images into an array then preload them like so using jQuery.
http://stackoverflow.com/questions/476679/preloading-images-with-jquery
You will however need to build the array as images are added in your .ascx file which depending on how you are doing so can be accomplished in your code and passed as a Literal or ViewBag variable to the JavaScript.
khayalian
Member
127 Points
143 Posts
Re: Preloader
Jan 09, 2013 01:29 PM|LINK
Thanks i found solution like this this one is very good if you have 10 -20 images, but i have to preload 1000 images.
jprochazka
Contributor
4846 Points
740 Posts
Re: Preloader
Jan 09, 2013 02:37 PM|LINK
JavaScript has to know what image to preload. There is no way to preload the image without the browser knowing the image it is to preload.
khayalian
Member
127 Points
143 Posts
Re: Preloader
Jan 09, 2013 03:14 PM|LINK
so i should write down all the images ?
markfitzme
Star
14411 Points
2226 Posts
Re: Preloader
Jan 09, 2013 04:10 PM|LINK
You will have to tell the javascript all of the images, it can't scan the server to determine them. Also, that number of images loaded into the client may cause issues because that's a lot of memory you are attempting to use on the client's computer and may result in their browser crashing. If it's a mobile browser on a cellular connect, you could eat up a large chunk of their bandwidth with the pre-loader. It also has the potential for not allowing the browser itself to properly cache the images as it normally does.
jprochazka
Contributor
4846 Points
740 Posts
Re: Preloader
Jan 09, 2013 05:50 PM|LINK
If you are pulling the images dynamically you can add them at that time to a string you can build to use as an array which you can pass to your JavaScript using a Literal or viewbag variable.