Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Registering a dynamic javascript after an UpdatePanel's update

I have a page with a dynamicly created javascript (the script is pretty static really, but the value of its variables are filled based on user input).

The result and the controls to take user input is inside an UpdatePanel which updates itself on certain user intputs. Some of these userinputs cause changes in the variables i spoke of earlier so i need to register a new javascript.

The problem ofcourse is that only the updatepanel gets updated and the scripts are registred outside the update panel so no new scripts are added.

What do you think would be best practice now? I could solve this by letting this script (and variables) live inside the updatepanel or i could make sure the page is fully reloaded when the need for posting a new javascript arises? The ScriptManager that i already have on the page might be able to help me with this...

So i'm looking for someone who either had similar problems and solved them in a nice way, or just someone with some bright ideas :)

like image 228
Per Hornshøj-Schierbeck Avatar asked Jan 28 '09 11:01

Per Hornshøj-Schierbeck


2 Answers

Have a look at ScriptManager.RegisterClientScriptBlock.

like image 144
Crescent Fresh Avatar answered Oct 15 '22 14:10

Crescent Fresh


I've had better luck with ScriptManager.RegisterStartupScript than I did with ScriptManager.RegisterClientScriptBlock. You might give that a shot.

like image 33
Jason Anderson Avatar answered Oct 15 '22 15:10

Jason Anderson