Click here to Skip to main content
Rate this: bad
good
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
Comments
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.
--SA
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?
 
--SA

1 solution

Rate this: bad
good
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.
 
Regard
Pawan
  Permalink  

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



Advertise | Privacy | Mobile
Web02 | 2.8.141022.2 | Last Updated 5 Nov 2012
Copyright © CodeProject, 1999-2014
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