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