Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running javascript whenever UpdatePanel refreshes

I am using an asp.net update panel to refresh the content on a page when a menu item is selected.

Within the content that is updated are images which have a javascript reflection function which is triggered with the following line of code:

window.onload = function () { addReflections(); }

This runs fine when the page is first loaded but not when a menu item is selected and the update panel is run.

On previous projects using jquery code I have replaced document.ready with function pageLoad but there is no document.ready on this page.

like image 370
Tom Avatar asked Nov 15 '25 06:11

Tom


1 Answers

Like this:

<script>

        // ASP.NET AJAX on update complete   
        var prm = Sys.WebForms.PageRequestManager.getInstance();
        prm.add_endRequest(function(sender, args) {
           // your code here, eg initToolTips('/Common/images/global/popup3.gif');
        });
like image 75
Mark Holland Avatar answered Nov 17 '25 20:11

Mark Holland



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!