views:

209

answers:

0

Hi all!

I've been googling this for days. Found a few threads about similar issues, all without any meaningful answers... Maybe someone here can enlighten me.

I'm developing an AJAX.NET application in VS2005 (.NET 2.0 with AJAX extensions). There's just one page that has a navigation panel and a content panel. Basically, both panels are UpdatePanels. When the user clicks a link in the navigation panel I catch this on server (in async postback) and load the appropriate user control into the content panel, so that it always contains just one control. Some content controls have to use javascript bits. I usually add script in the control's Pre-Render handler by calling ScriptManager.RegisterClientScriptBlock/RegisterStartupScript.

My concern is that in each async postback script registration methods are called again and again and I didn't find a way to check if the script block was already registered in previous postback(s). For now I have two problems.

  1. After each async postback a bunch of scripts is added into the page head, even if the same control is being loaded into the content panel each time. I've noticed this using Firebug HTML view. I believe this means that the page memory consumption is increasing with each click.

  2. I've ran into problems trying to implement a simple countdown timer in a content control. Calling javascript setTimeout(...) from startup script block adds one more "ticker" with each postback. This actually might be a good thread starter on its own.

I'll happily add more details if anyone is interested in looking into this. Thanks in advance.