I have a user control that has a timer in it. The timer is being updated every 5 seconds using javascript within the user control itself. During run time, a few instances of my user control is created. I place them inside an update panel. The timer works just fine when there is only one instance of my user control. But when there is more than one instance, only the last instance gets updated every 5 seconds. The earlier instances don't get updated.
Here's my javascript:
var start = new Date('<%=session.startTime%>');
var stat = '<%=session.status%>'
UpdateValues();
AutoUpdateValues();
function AutoUpdateValues(){
setInterval(function () {
UpdateValues();
}, 5000);
}
function UpdateValues() {
//update time elapsed
var totalSec = Math.ceil((new Date() - start) / 1000); //time elapsed in seconds
var hr = Math.floor(totalSec/3600);
var min = Math.floor((totalSec % 3600)/60);
var sec = totalSec % 60;
if (stat == 2) {
$('#<%=lblTimeElapsed.ClientID%>').text(hr + "h " + min + "m " + sec + "s" );
}
}
I read about the use of passing the context to my method here but I don't know how to implement this in my code. Any help, please? Thanks