How do I perform an action after an UpdatePanel updates?
-
03-07-2019 - |
Question
When I have a regular textbox in a UpdatePanel (not an ASP.NET control) with some JavaScript events on it, after the UpdatePanel updates my events are gone. Is there a way to re-attach my events after the update? (Preferably without putting my events inline).
Solution
You can use the endRequest event of the PageRequestManager class.
OTHER TIPS
You can have a setInterval()
loop on document load that would search for the element in the update panel and if it didn't have the events, it can re-attach them.
The events are gone because your textbox is a new element in the DOM (after the UpdatePanel refresh). As said by korchev, use the endRequest event to re-attach the eventhandlers.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow