Controls in UpdatePanel lose jQuery events

I have a button located in an updatepanel control. A button click event has a function defined for it through jQuery. After the asynchronous postback is completed, the jQuery event does not fire when the button is clicked later. What do I need to do to fix this behavior and maintain the binding of the jQuery event to the button click event after it is updated asynchronously?

+6
jquery
source share
1 answer

bind the jquery event handler handler inside the following function

function pageLoad(sender,args) { // binding code here, for example $('#button').click(function(e) { // do something when the click event is raised }); } 

pageLoad is executed after each postback, synchronous or asynchronous. pageLoad is the reserved function name in ASP.NET AJAX designed for this purpose. $(document).ready() , on the other hand, is executed only once when the DOM is initially ready / loaded.

See ASP.NET AJAX Client Life Cycle Overview

+15
source share

All Articles