Tags: ajax, animation, aspnet, clear, inetrval, javascript, net, panel, pretty, setinterval, update

update panel setinterval

On .Net » ASP.NET AJAX

2,872 words with 1 Comments; publish: Sat, 05 Jan 2008 22:47:00 GMT; (10062.99, « »)

in my update panel i kick off an animation that uses setinterval. the javascript will clear the inetrval when the animation is done.

Pretty standard

however if i do another partial postback on a diff panel the interval will never clear. somehow the instance of the interval is lost. Has anyone encoutnered this?

//initalize animation

function Animate()

{

snapCurrent = 0;

layerClicked='imgBar'

snapTimer = setInterval("scrollOut(layerClicked)", 20);

}

function scrollOut(imgToSnap)

{

var beginTime;

beginTime= readCookie("dlStart");

var d =new Date()

var currTime = d.getTime()

var elapsedTime = currTime-beginTime

var seconds = elapsedTime/1000

var percentage= seconds / aniTime

var pixels =finalWidth*percentage

$("testBox").value=seconds;

if (seconds <= aniTime)

{

document.getElementById(imgToSnap).width = pixels ;

}

else

{

clearInterval(snapTimer);

snapTimer=null;

divOn("info");

updateState();

setSessionCookie("dlStart","")

}

}

All Comments

Leave a comment...

  • 1 Comments
    • I found the culprit and its me. i was running the js again on the partial postback

      Page.ClientScript.RegisterStartupScript(GetType(), "key", js);

      that a no no

      oops

      #1; Sat, 05 Jan 2008 22:49:00 GMT