Wednesday, 15 August 2012

.net - Javascript not loading right when using updatepanel -


I have had to cope with a difficult bug, I'm not sure if there is a good way to solve it. But I have a page (.aspx) that has control called widget. The widget appears several times in the page. And each widget has a lot of JS and jquery, some of them read properties from control. My problem is that the control is a partial postback and JS is not being refreshed with the new values. If I re-register the JS, then JS is called twice, containg one true values ​​and one containing the old values. I have googled and noticed that it is not possible to remove the script added in ScriptManager.RegisterStartupScript, so for my question is there any smart way to call an old JS or replace it with the new JS with the right values?

From my experience, it really is not possible. I have participated first on this, and found the solution, but it always takes a new bug / issue / problem together with the updated panels and javascript.

I recommend that JavaScript is not attached to the code on which the update panel is used

Personally, I do not use update panels at all, because your Because of all the problems, I have to face. What I do instead, I create my SS ASP.NET AJAX controls that implement the ISSC control, which set up web services with the [scriptsvilege] attribute. Having the ScriptService attribute will create client script methods that you can easily call in your JavaScript code, and manage all the disturbances for you.


No comments:

Post a Comment