Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

initial jquery not working when updatepanel is updated

I have reviewed posts about this issue but none of solutions seem to work for me.

I have a js file with jquery scripts which is loaded in head section of the page

I have also an updatepanel which holds a child usercontrol where my trigger button is placed. The updatepanel is updated when a child button is clicked correctly.

Everything works fine except that jquery doesn't work anymore.

I found info that $(document).ready does not work on partial postback so it is the case of my updatepanel.

I have also found information that adding path with ScriptReference can work so I added this to my Page_Load of the usercontrol holding UpdatePanel:

    ScriptReference sr = new ScriptReference("~/js/jquerycripts.js");
    ScriptManager.Scripts.Add(sr);

But it doesn't work either.

Not sure what else to try.

Any advice would be helpful.

Thank you

like image 937
nickornotto Avatar asked Dec 01 '25 15:12

nickornotto


1 Answers

You can use this code instead of $(document).ready(YourFunctionName);

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(YourFunctionName)
like image 107
Boriss Pavlovs Avatar answered Dec 04 '25 06:12

Boriss Pavlovs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!