Monday, March 26, 2012

UpdatePanel - Wits End - Take Pity

i have an UpdatePanel with mode="Conditional". when a button within the UpdatePanel is clicked it is firing an Atlas partial postback.

i am trying to register a script on each postback. but when the partial postback occurs my script is not getting refreshed. my script is attempting to register itself in Page.PreRender. below is the code in case that it important. please help - im at my wits end with this - thanks

if (!Stopwatch.IsTicking)

script ="var isTicking='F';var hrs=0;var mins=0;var secs=0;";

else

{

TimeSpan timeElapsed =Stopwatch.TimeElapsed;

script ="var isTicking='T';var hrs=" + timeElapsed.Hours.ToString()

+";var mins=" + timeElapsed.Minutes.ToString() +";var secs="

+ timeElapsed.Seconds.ToString() +";";

}

Page.ClientScript.RegisterClientScriptBlock(Page.GetType(),"SWVars", script,true);

Hi,

try to use Page.ClientScript.RegisterStartupScript() instead. Inline scripts in an UpdatePanel are not loaded after a partial postback.


Nope. Hasn't made a difference. Any other suggestions?

Try using Fiddler or Nikhil's Web Dev Helper to do an HTTP trace and see if your script is getting sent down to the client at all.

If it's being sent down, try adding the "debugger;" statement to the top of your script to launch the debugger the moment it's executed (it works in IE, not sure about other browsers).

If it's not being sent down, well, I'll take another look :)

Thanks,

Eilon


When I install Fiddler I get an "unknown error" popup when i click the button within my updatecontrol.

when i uninstall Fiddler this message goes away?


ignore. ive fixed this problem now.

What was your solution to this. I've come across this same problem. Thanks.


i used RegisterClientStartupScript. as it happens the problem was down to my javascript. the javascript ran ok without atlas but i needed to tweak it slightly to run with atlas.

my advice to you is to check your javascript.


If you're using ClientScript.RegisterXxx() and you've simplified your JavaScript down to something that still doesn't work, please share snippets of your code and I'll be glad to take a look.

Thanks,

Eilon


When you have ClientScript.RegisterClientScriptBlock, there is something about the order in which the script is executed, related to Atlas scripts.

As far as I can remember, if you are using an UpdatePanel, your script executes after Atlas scripts.

If you are not using an UpatePanel it executes before.

No comments:

Post a Comment