Refresh Parent Page

  • Thread starter Thread starter Ben Schumacher
  • Start date Start date
B

Ben Schumacher

How can I refresh the parent page from a popup window that was created using
window.showmodaldialog? I would like to accomplish this using vbscript if
possible.
 
You can always use java script to refresh the parent page...

window.opener.callMyRefreshFunction();
 
I don't want to call call a routine on the parent page. I want to handle
everything in the modaldialogwindow popup window.
 
I was just giving an example of calling routine. You can access any JS
variables (control instances etc.)on parent page from child window. You will
have to do it via JS.
What exactly you are trying to do then I may be able to give you more
specific answer about refreshing UI on parent page.
 
Ok. I have a page with a gridview control which is used to display a list
of records in a database table(s). If the user wants to add a new record,
they click "new" and a popup window displays. The popup window accepts data
from the user (name, number, date, etc) and is then submitted back to the
server when the users clicks an ok button. At this point I want to update
the database with the new record, close the popup window, and then refresh
the parent page so that it reflects the newly added record that was created
using the popup window.
 
You need to emit client script into the page. A literal way to do it:

Response.Write("<script>window.opener.location.href=window.opener.location.href;</script>");

That's C#, but in VBScript you only need to add the language attribute to
the script tag and remove any semicolons. Javascript is better as only IE
understands VBscript.
Peter
 
when i just try to look at what the href property is of the opener object
i'm getting Object required: 'window.opener'. Here is the code I'm using in
the popup window that is created using window.showmodaldialog.

<script language="vbscript" type="text/vbscript">

Sub window_onload()

document.write(window.opener.location.href)

End Sub

</script>

Any more ideas?
 
Ben,

Unfortuntately, Window.Opener isn't an object when you use
Showmodaldialog. To access the opener window object you can pass a
reference to it like this:

<parent-page>
window.showModalDialog( 'modal_window.aspx', window, '' );
</parent-page>

<modal-window>
var parentWindow = window.dialogArguments;
document.write(parentWindow.location.href);
</modal-window>

This may not work on all browsers, check documentation for browser
support other than IE.

I hope this helps,
Carl
 
Back
Top