I am trying to use a VB.NET AJAX Timer control within a Repeater. I cannot figure out how to get this to work. The timer needs to constantly check the server to see what time it is and then display a live countdown clock based on a given time. I have the code that does this and works successfully outside of the repeater. Just can't figure out how to do a separate timer for each item within the repeater.

put the timers outside of the repeater and wrap the repeated items in updatepanels. Use triggers in the updatepanel that are tied to your repeater control(s)

bstl, tks for the response.

Can you please provide simple sample code for what you are describing? I do currently have updatepanel within my repeater that works properly. What I don't know how to do is reference the timer control from within the repeater. Or rather, reference the items within the repeater from the Timer_tick event that fires outside of the repeater. I have been trying to figure this out for weeks and no one seems to have an answer.

Let me make sure I understand what you want. You have a server side repeater which is rendering similar items to your page. Then what you want to do is update said items on independent intervals and draw something else, right? So if it was rows you were rendering, it would be row 5 updates itself every 30 seconds with the latest data or something like that. Is that correct?

I've attached a screenshot of my page. It's a online auction that each item has a close date. I need a timer that will display a countdown for each item showing time left until auction close date.

Oh, my mistake, an Ajax timer control, at least the Ajax timer control is used to create postbacks on intervals to update content on the page asynchronously. Sounds like what you need is some javascript to update text in a div every second. Here's one site a found with just a quick google search for "javascript countdown timer": http://www.ricocheting.com/code/javascript/html-generator/countdown-timer. Best of luck and be sure to check out my blog for more tips: http://antitrevblog.blogspot.com/

Yeah, I've googled that too. Wasn't able to find a solution that worked within the .NET repeater.

I don't understand, what is that blog for?

The .net repeater just renders controls to the page, once those controls are rendered anything that happens without a post back is javascript or some similar tech. Use the repeater to create the things, and have the start date in a div inside each repeated item. Then when the page renders, have a start up script to look for all the divs, get the dates out, and start running that code on that site. The JS will start updating the text/dates and boom! done. The repeater is a server side control, you need client side JS.

sudo code:

<body onload="StartCountdowns();">

function StartCountdowns()
var divs = getElementsByTagName('div');
for each div in divs
if div.id.substring(0,5) == 'datediv'
send date and div id to code from dudes site

yeah, just don't know how to reference the repeater controls since it's a dynamic amount of rows with dynamically assigned names. if you think you have the know how to make this happen, i'd be happy to pay you and resolve this off board.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.