How to execute javascript after updating the update panel (cannot get Sys.WebForms.PageRequestManager.getInstance (). Add_endRequest (); work)

I am trying to run javascript after updating the update panel. I read a few places where you can use code similar to this:

function codeToRun() {
    //Code Here
}

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(codeToRun);

But it doesn't seem to work ... any ideas? I tried to put the code in the content area of ​​the update panel, and also beyond it ... until I got lucky. Please let me know if you have an idea of ​​why this might happen.

Thanks
Matt

+3
source share
2 answers

Everything should be outside of UpdatePanel:

:

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

Script:

if( typeof(Sys) != "undefined" )
{
    Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(initRequestHandler);     
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);   
}
else
{
    //we have a problem with ScriptManager
}
+5

System.WebForms.PageRequestManager , , , , UpdatePanel.

0

Source: https://habr.com/ru/post/1721116/


All Articles