Search code examples
jqueryasp.netasp.net-ajaxmicrosoft-ajax

Execute JQuery after ASP.Net Microsoft AJAX


I'm trying to execute JQuery after an ASP.Net Microsoft AJAX post back.

When a user clicks on a link, Microsoft AJAX is used to update some fields in the DB and if success a label appears informing the user the change has been made. Unfortunately the label is not very obvious and I would like to use to fade the background from red to white.

The problem is that when visible=false is set on the label, the resulting html does not include the label(span). Does anyone know how to execute JQuery after an ASP.Net Microsoft AJAX post back, or another solution to achieve the same affect?


Solution

  • This is how you can execute a random javascript after an ASP.NET Ajax postback

    function executeThis(){
    //code here to fade in out the label that comes
    
    
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.remove_pageLoaded(executeThis); //job done, remove this so that it is not fired again.
    }
    
    
    $("link").click(function(){
                    var prm = Sys.WebForms.PageRequestManager.getInstance();
                    prm.add_pageLoaded(executeThis); //this will register executeThis function with MS Ajax libraries which will fire it after next posback
                   //the post back happens here.
      });