3

I put the following javascript code inline but it doesn't trigger after the updatepanel is done with its postback:

function EndRequestHandler(sender, args) { alert("this should work"); }
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

Any ideas?

Thanks.

frenchie
  • 51,731
  • 109
  • 304
  • 510
  • 2
    possible duplicate of [ASP.NET - UpdatePanel and JavaScript](http://stackoverflow.com/questions/418072/asp-net-updatepanel-and-javascript) – jcolebrand Feb 09 '11 at 04:36

4 Answers4

3

ok, nevermind, I got it. If someone else runs into this problem, put the sys.webforms..... line like this:

$(document).ready( function () { sys.webforms....; }
frenchie
  • 51,731
  • 109
  • 304
  • 510
1

Do following thing place following function on dom load.

function load() {
  Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
}
santosh singh
  • 27,666
  • 26
  • 83
  • 129
0

This may be help you.

var prm = Sys.WebForms.PageRequestManager.getInstance();
if (prm != null) {
    prm.add_endRequest(function (sender, e) {
        if (sender._postBackSettings.panelsToUpdate != null) {
            DisplayCurrentTime(); // here your javascript function
        }
    });
};
Apps Tawale
  • 665
  • 7
  • 7
0

Just to clear up the confusion here is the full code

function EndRequestHandler(sender, args) 
         { yourFunction(); }

jQuery(document).ready(function (){
         Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
      });

Hope this helps!

envyM6
  • 1,099
  • 3
  • 14
  • 35