The combination of Asp.net Ajax and Asp.net is perfect, and Jquery is inevitable when it is not enough. Jquery and Asp.net Ajax are also common in combination. If they are well handled, they will not conflict with each other. However, it was recently found that when Jquery's ready () function came back from PostBack, the action executed in ready was actually invalid. First impression: will Asp.net Ajax conflict with Jqueryd's ready, then remove the Asp.net Ajax script reference, and everything is normal. After thinking about it, I finally added add_endRequest () to Asp.net Ajax ScriptManager, and Jquery's ready finally got back to normal.
| The code is as follows: |
Copy code |
<Script type = "text/javascript"> Sys. WebForms. PageRequestManager. getInstance () . Add_endRequest (EndRequestHandler ); Function EndRequestHandler (sender, args ){ If (args. get_error () = undefined ){ PageInit (); } } Function PageInit (){ $ (Document). ready (function (){ // TODO }); } PageInit (); </Script> |
Add the above code and pay attention to it. If this script is placed in the head, an error will occur, prompting the Sys object undefined, because the ScriptManager of Asp.net Ajax, if the state is not complete, the Sys object cannot be found, and the script is placed at the end of the body, everything is normal.