Click here to Skip to main content
11,715,491 members (75,026 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET Javascript
Hello all,

I have an obligation to do a image rotation/change in every few seconds. I want to accomplish this by javascript.

I know i can do it by using a update panel but using javascript is a must for me. Some fallbacks are:

I have bumped into some javascript codes that rotates the images in a few seconds but they use an image path. I saved my images in a database so I dont have an actual file to point at. So can someone explain to me how i can do this? maybe if possible, some examples help a lot. Thank you very much.
Posted 4-Nov-12 8:06am
Sergey Alexandrovich Kryukov at 4-Nov-12 14:20pm
Not clear. If you do it purely on client side and the client does not change anything, seconds are irrelevant.
wonder-FOOL at 4-Nov-12 14:26pm
Sorry for my english. I will try to rectify it again. I have images stored in a database. I want these images to be displayed in my webpagein a time interval. I want to accomplish this by using javascript. I dont know how I should display them meaning even which control I should use to load the images and write a code in javascript which will change the images lets say in every 5 seconds. I dont know if this made it clear.
Sergey Alexandrovich Kryukov at 4-Nov-12 19:31pm
JavaScript is on client side, database (or any other storage of images) is on server side. So, if you send Ajax HTTP request sent ever 5 seconds, you can write server code which updates the picture on each request. Learn Ajax, jQuery would be also useful, to send those requests...

I must add that such behavior is a bad idea; it will irritate most users. The user reasonably expect that everything is changed only on there requests. Many sites violate this principle, but it simply means that 99% of sites suck. Don't you think so?


1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

create a simple handler, i.e., .ashx file. That returns the actual images from database once you access this handler with a parameter.For example the url abc.ashx?img=1 should return the first image file abc.ashx?img=2 should return the second one. And use this url as image names/path in your javascript file.


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 485
1 Richard MacCutchan 275
2 Maciej Los 259
3 ManasKumarM 155
4 Frankie-C 125
0 Sergey Alexandrovich Kryukov 785
1 CHill60 415
2 Richard MacCutchan 405
3 Maciej Los 389
4 OriginalGriff 320

Advertise | Privacy | Mobile
Web01 | 2.8.150901.1 | Last Updated 5 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100