Invalid Javascript script of updatepanel in ASP. NET

Source: Internet
Author: User

Invalid Javascript script of updatepanel in ASP. NET

Question: The approximate meaning is as follows:

<Updatepanel> <contenttemplate> <asp: textbox id = "AAA"/> </contenttemplate> </updatepanel>

<SCRIPT> $ (document ). ready (function () {var id = "<% = aaa. clientid %> "; $ (" # "+ id ). click (function () {alert ("AAA") ;}); </SCRIPT>

When you click textbox for the first time, a dialog box is displayed. However, after refreshing, the dialog box becomes invalid. How can this problem be solved?

A: Because updatapanel does not have PostBack, your JS will not be reloaded. So it becomes invalid. You add a section like this on your page.CodeYou can: <SCRIPT type = "text/JavaScript" Language = "JavaScript"> var PRM = sys. webforms. pagerequestmanager. getinstance (); PRM. add_endrequest (function () {// re-bind your jquery events here

$ (Document ). ready (function () {var id = "<% = aaa. clientid %> "; $ (" # "+ id ). click (function () {alert ("AAA ");});});}

); </SCRIPT>

Original article: http://zhidao.baidu.com/question/250731985.html

 

The JS invalidation issue in updatepanel 2010-06-21 18: 02updatepanel does not retain any effect generated by JavaScript or other client technologies (such as Adobe Flash.

Therefore, after partial refresh, you must register JS again.

Practice:

Function endrequesthandler () {// js to be run after refreshing} function reload () {sys. webforms. pagerequestmanager. getinstance (). add_endrequest (endrequesthandler);} $ (documnet) in jquery's ready ). ready (function () {reload ();}) Original: http://hi.baidu.com/a_longge2009/blog/item/9956cb23ca971ea94723e849.html

 

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.