Controls in UpdatePanel losing JQuery Events

后端 未结 1 1073
余生分开走
余生分开走 2021-02-04 18:33

I have a button that is within an updatepanel control. The button\'s click event has a function defined for it through JQuery. Once the async postback completes the JQuery eve

相关标签:
1条回答
  • 2021-02-04 19:30

    put your jquery event handler binding 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 every postback, synchronous or asynchronous. pageLoad is a reserved function name in ASP.NET AJAX that is for this purpose. $(document).ready() on the other hand, is executed only once, when the DOM is initially ready/loaded.

    See this Overview of ASP.NET AJAX client lifecycle events

    0 讨论(0)
提交回复
热议问题