How to refresh the parent window when the modal window closes

Source: Internet
Author: User
Tags query tostring
Parent window | Refreshing in a project often encounters a situation where you want to modify the data in the parent page in the pop-up window. This article takes the modal window as an example of how to refresh the contents of the parent window after the Schema window page is updated.

In general, the shutdown of the modal window does not refresh the parent window, and we need to add an extra script to refresh his parent window in the JavaScript of the Open mode window.
Implemented as follows:

String url = "Icmanageadd.aspx?" Icid= "+icid+" &temp= "+rd. Next (). ToString () + "&username=" +session["UserName"]. ToString ();
E.ITEM.CELLS[4]. Attributes.Add ("Style", "cursor:hand;");
E.ITEM.CELLS[4]. Attributes.Add ("onclick", "window.showModalDialog") (' +url+ ', ', ', ', ' dialogwidth=700px;dialogheight=600px; status:no; Help:no; '); Window.location.reload ();)

This statement adds the pop-up mode window to a column in the DataGrid and modifies the detailed data for a row in the DataGrid in a pop-up window. Because the pop-up of the modal window will interrupt the execution of the parent window page, we can add a refresh to our page after the pop-up mode window: Window.location.reload (). The effect is to refresh the entire parent page after the modal window is closed.

But this function does not meet the needs of a good, such as the parent page DataGrid data is clicked on the page Query button, and then refresh the entire parent page is not appropriate, resulting in a very poor user experience. To refresh in this case, we can use JavaScript to simulate clicking on the page's query button so that both the content is updated and the records in the DataGrid are preserved.
Implemented as follows:
Replace Window.location.reload () with document. Form1.btnSearch.onclick (); Where btnsearch is the ID of the parent page Search button

Finally, the modal window should not cache content, add in CS

Response.Expires = 0;

This solves the problem of refreshing the mode window



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.