Call Javascript in the updatepanel control in Atlas and some principles of updatepanel

Source: Internet
Author: User
The updatepanel control is available in Atlas and supports partial update. You only need to specify mode = "Conditional". Of course, you must also set enablepartialrendering = "true" for scriptmanager ".

Partial update: XMLHTTP is used. The process is as follows:
1: When PostBack is enabled, the page JS will PostBack the data on the page (PostBack is required for the entire page)
2: the backend receives the request and starts processing (pageload of the page can be triggered)
3: after processing, send the data to be updated back to the page (based on the name of the updatepanel you want to update, determine the data to be sent back. This is the sentence "This. updatepanelxx. Update ()".Code)
4: The page (client) only updates this part of the response data (this is called a local update, the method is to find the updatepanle, and then updatepanel. innerhtml = postbackdata. Is a direct replacement .)

From this point of view, the so-called local and new is to only redraw the specified updatepanel part (When sending back the server, the whole page must be sent back. The background code is also processed in the same way as before. However, only part of the processing result is returned to the client.).

In this way, if you want to trigger a page JS processing during updatepanle processing, it will be very difficult. Because all the data you send back is updated to a small corner, the previous response. Write (JS) does not work at all.

The solution is as follows: This. Page. clientscript. registerstartupscript (This. GetType (),"Openoverviewpart", Openscript );

Use the registerstartupscript method to register JS functions, and then you can run them smoothly.

In fact, the execution is not so smooth, because after the implementation of Atlas is partial and new, it will put all the JavaScript code on the page together-be nosy-so it will cause some minor impact: many JavaScript codes have such functions as <! -Annotation symbols such as. Accidentally, your own JS will also be commented out. This is indeed troublesome.
The solution is to compare X. You need to control the JS output style by yourself, and add a few more carriage return lines to show that it is not a comment. String Openscript =   " \ N \ t " ;
Openscript =   " <Script "   +   " Type = 'text/JavaScript '> \ r \ n "
+   " \ R \ n "
+   " VaR a = 0; \ r \ n "
+   " Opener. Top. _ dopostback (' "   + Request. Params [ " Refresh " ] +   " ', 'Refresh'); \ r \ n "
+   " Window. opener. Focus (); "
+   " Window. Close (); "
+   " < "   +   " /Script "   +   " > " ;

Related Article

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.