UpdatePanel and controls with javascript
-
Suppose I have a server control which executes some javascript function on every page postback. For the sake of simplicity, let's say it renders like this:
My control
window.alert('My control is in the page');This, of course, works, a popup window is displayed on every postback. Now imagine that the control is nested in an UpdatePanel control. Then the popup is displayed on full page postbacks, but not on partial postbacks where only the UpdatePanel is refreshed (although the javascript is still rendered to the page, it is not executed). My question is: How do I execute some javascript function on truly every postback, partial or full? It is obvious that "standard" methods for such scenario, like RegisterClientStartupScript, are out of the question. (As an example, if I want to write my own Timer server control, I need the execute some javascript which after some time interval causes postback. This is easy with full page postbacks, when this javascript is normally executed, but when the Timer is in UpdatePanel (and enabled during partial postback), I need to run the javascript after the partial postback, which I cannot see how.)
modified on Tuesday, February 16, 2010 3:30 PM
-
Suppose I have a server control which executes some javascript function on every page postback. For the sake of simplicity, let's say it renders like this:
My control
window.alert('My control is in the page');This, of course, works, a popup window is displayed on every postback. Now imagine that the control is nested in an UpdatePanel control. Then the popup is displayed on full page postbacks, but not on partial postbacks where only the UpdatePanel is refreshed (although the javascript is still rendered to the page, it is not executed). My question is: How do I execute some javascript function on truly every postback, partial or full? It is obvious that "standard" methods for such scenario, like RegisterClientStartupScript, are out of the question. (As an example, if I want to write my own Timer server control, I need the execute some javascript which after some time interval causes postback. This is easy with full page postbacks, when this javascript is normally executed, but when the Timer is in UpdatePanel (and enabled during partial postback), I need to run the javascript after the partial postback, which I cannot see how.)
modified on Tuesday, February 16, 2010 3:30 PM
How to call client-side Javascript once an UpdatePanel request is over[^] Or you could refresh the update panel from JavasScript Easily refresh an UpdatePanel, using JavaScript[^] and call your script from there.
I know the language. I've read a book. - _Madmatt
-
How to call client-side Javascript once an UpdatePanel request is over[^] Or you could refresh the update panel from JavasScript Easily refresh an UpdatePanel, using JavaScript[^] and call your script from there.
I know the language. I've read a book. - _Madmatt
Thanks, this helped a lot. I also learned that
ScriptManager.RegisterStartupScript
method simplifies this functionality. H