UpdatePanel Causes JS failure solution (reprint)

Source: Internet
Author: User

The whole page is made with Microsoft's AJAX framework, under the spit groove, to maintain the project that someone else did before the egg hurts.

Today to repeater with JS write a hover event

<Scripttype= "Text/javascript">        $(function(){            $('. Trhead'). Click (function(){                $( This). Next ('. Trcontent'). Find ('. Divcontent'). Slidetoggle ('Fast');            }); $('. Trhead'). Hover (function(){$( This). CSS ("background",'RGB (215,215,215)');},                function(){$( This). CSS ("background",'#fff');}        ); })          </Script>

Results repeater turned to the second page, the effect is invalid, that is, JS has not.

At this time, it was

    protected void Aspnetpager3_pagechanged (object  sender, EventArgs e)    {        binddata ();         // re-register JS event        after binding data " AA " " AA () " true );    }

and this AA () function, of course, is:

    <Scripttype= "Text/javascript">        functionAA () {$ ('. Trhead'). Click (function(){                $( This). Next ('. Trcontent'). Find ('. Divcontent'). Slidetoggle ('Fast');            }); $('. Trhead'). Hover (function(){$( This). CSS ("background",'RGB (215,215,215)');},                function(){$( This). CSS ("background",'#fff');}        ); }    </Script>

That is, the onload to execute the JS, put in a Method AA (), after the paging binding data, re-register a bit.

Similarly, when another control is returned, it needs to be re-registered.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.