Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close popup and refresh main form. 2

Status
Not open for further replies.

abrewis

Programmer
Oct 16, 2001
37
0
0
GB
I have an application with a datagrid with 'Add' buttons on each row. When the user clicks the add button a popup form listing suppliers is displayed. Once a user has selected the supplier details are sent to the database. I then want the popup to close and the main form to refresh so that the supplier is displayed in the datagrid against that particular record.

Do I force a refresh from the popup form or the main form? And how do you call it?

Many thanks in advance
 
once the popup is closed and focus is returned to the main page, I belive a post back is triggered. Refresh the data in the pageload.
 
Hi,
the main page doesn't trigger a postback when the pospup is closed. The only postback is triggered when the popup is loaded. Or am I closing the popup incorrectly?

This is my code to close the popup:

Dim strScript As String = "<script>window.opener.document.forms(0)." + control.Value + ".value = '"
strScript += sReturn
strScript += "';self.close()"
strScript += "</" + "script>"
RegisterClientScriptBlock("anything", strScript)

Many thanks
 
Dim strScript As String = "<script>window.opener.document.forms(0)." + control.Value + ".value = '"
strScript += sReturn
strScript += "';opener.location.reload();self.close()"
strScript += "</" + "script>"
RegisterClientScriptBlock("anything", strScript)

a few things:
--> if there any postback had happened before the popup was opened then the browser will ask a question like "Do u want to refresh the page...." with a "Retry" and "Cancel" option.

normally i have a submit button in my page and using the following script i force it to call the click() event of the submit button.

try this:
opener.document.getElementById("SubmitBtnId").click()


Known is handfull, Unknown is worldfull
 
Another option is to open the popup as a childwindow and then force a post back when the variables are transferred on close of the window.

For example, the javascript attached to the "Close" button on the popup is as follows:
Code:
<script language="Javascript">
function ReturnY1(Y1Max, Y1Min){
var Y1Max;
var Y1Min;
window.opener.document.forms["Form1"].elements["txtY1Max"].value = Y1Max;
window.opener.document.forms["Form1"].elements["txtY1Min"].value = Y1Min;
window.opener.document.forms["Form1"].submit();
window.close();
}      
</script>
Here the new variables are passed to textboxes in the main form (Form1) and the form submits once the variables are set.

I like vbkris's method but have not tested it; looks good (will stick it in the card catalog for future reference).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top