Showing posts with label updatepanels. Show all posts
Showing posts with label updatepanels. Show all posts

Monday, March 26, 2012

Call JS at end of UpdatePanels content loading

I'm trying to figure out how to call a javascript method at the end of an UpdatePanel's content reloading. I know this must be possible, but I'm not seeing how yet.

Here's what I have: one page with an update panel. Contained within the update panel is a series of controls, much like a wizard. Each control has a button that posts back to the server, which then loads a different control. By using the UpdatePanel, the postback is hidden, which is nice. What I want is for every time the control within the UpdatePanel is changed for some custom javascript to run. The script just resets a page-scoped timer that notifies the user his session is about to expire. How can I hook in to the postback and run my one line of script? Thanks.

Of course after hours of searching and posting I finally find an example using the PageRequestManager that does the trick nicely. For the record, the simple script was:

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args)
{ extendSession();// My JS method }