开发者

call javascript after updatepanel postback

开发者 https://www.devze.com 2023-02-09 04:13 出处:网络
I put the following javascript code inline but it doesn\'t trigger after the updatepanel is done with its postback:

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"); }
开发者_Python百科Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

Any ideas?

Thanks.


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

$(document).ready( function () { sys.webforms....; }


Do following thing place following function on dom load.

function load() {
  Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
}


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
        }
    });
};


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!

0

精彩评论

暂无评论...
验证码 换一张
取 消