Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery event handler inside updatepanel not working after postback [duplicate]

Tags:

asp.net

I have a div with "id=ShowDetails". In my javascript I have this:

    $(document).ready(function () {
       UIactions();
    });

    function UIactions () {
        $('#ShowDetails').click(function () {
            alert("bingo");
          }
     });

The div is inside the update panel that gets posted back. When the page loads, if I click the div, I get the bingo but after the postback, I don't. Any idea why?

Thanks.

like image 535
frenchie Avatar asked Dec 09 '25 12:12

frenchie


1 Answers

I know that this is a really old post, but i came by this by having the issue that my jQuery script didn't work after content inside an update panel was updated.

I found an easy solution and all the other solutions are not worth looking at :)

Simple just remember to add your asp.net controls to the UpdatePanel's Triggers as postback.

<Triggers>
     <asp:PostBackTrigger ControlID="....." />
</Triggers>

Hope this help someone, because i have spent too much time on finding the solution.

like image 183
NoxiaZ Avatar answered Dec 12 '25 11:12

NoxiaZ



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!