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