Click here to Skip to main content
15,885,898 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi
I've got a question:

How can I switch the MenuItem in aspx with a timer

i want to change the MenuItem with a timer for example ervery 30sec the next MenuItem have to show

I can't find any help

Does anybody have a solution?

pls help
Posted
Updated 26-Jan-12 0:15am
v3
Comments
Dalek Dave 26-Jan-12 4:51am    
Do you mean Work Through a menu on a timer, or Switch Menus altogether?

More clarity and precision in the question leads to an increasingly perspicacious answer.
Kenny369 26-Jan-12 5:34am    
Ok i want to change the MenuItem with a timer for example ervery 30sec the next MenuItem have to show
ZurdoDev 26-Jan-12 8:11am    
Have you tried the AdRotator in ASP.Net? It isn't a menu but it sounds like you want a rotating ad. If not, there are a ton of Jquery menu samples that can do what you want.
Kenny369 26-Jan-12 8:34am    
thanks for your reply

I've got a solution

1 solution

A basic mechanism:

  1. Include jquery on your page
  2. Give your menu items ids like menuItem1, menuItem2 etc.
  3. Declare a counter varible in javascript and set it to 1.
  4. use jquery to hide the current menu item: $("#menuItem"+counter).hide()
    then add one to the counter test to see if the menuItem exists (see here[^]). If it doesn't, you have shown the last item, reset the counter to 1. Now show the net menuitem, code>$("#menuItem"+<i>counter</i>).show()
  5. Now loop. You can do this using either Javascript timing event[^] to call the function, or use jquery's delay method in the function in step 3, and have it call itself.


This won't be very smooth: to improve this get the next item first, show it, and use the show mehtod's callback to hide item that has just been finished with. See http://api.jquery.com/show/[^] for help how to do this. If you use the jquery delay you should add the recursive code to the callback.
 
Share this answer
 
Comments
fjdiewornncalwe 26-Jan-12 9:42am    
+5. Excellent.
Wonde Tadesse 26-Jan-12 21:18pm    
It seems like you already did it before :) 5+

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900