Click here to Skip to main content
15,901,122 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, hoping you guys can help me.
I'm familiar with bubbling events from a user control up to the page (parent) that the control resides on.

In this case - I have a page that opens a new window using :
btnBeginSurvey.Attributes.Add("onclick", "SurveyPopUp=window.open('survey.aspx', 'SurveyPopUp'); SurveyPopUp.focus()")


When the user finishes the survey, I want to close the child window and bubble an event up to the parent browser window telling it to refresh.

Can anyone please help me at all ?

Any help at all is gratefully received !

Thanks,
Scott
Posted

Well, it's not exactly "bubbling", but this should work - in your child window, whenever the survey is finished you can do something like:

<script type="text/javascript">
    function closeAndRefreshParent() {
        window.opener.location = window.opener.location;
    }
</script>
<input type="button" onclick="closeAndRefreshParent();" value="Close & Refresh" />


Or you can have a function in the parent window, and call it from popup whenever you want:

In the parent window:
function doSomething() {
 ....
}


And call it from the popup:
window.opener.doSomething();
 
Share this answer
 
v3
Comments
Wotney 5-Aug-10 6:34am    
Reason for my vote of 5
a nice, simple solution, thanks a lot !!

I did notice that the 'o' in 'onclick' has an umlaut on it, so it didn't work, but easy to fix :)
You can also look at this article, doing almost something similar: Partial update of parent page via AJAX (ASP.NET 2.0) on close of a child window - conditionally[^]
 
Share this answer
 
Comments
Wotney 5-Aug-10 6:35am    
Reason for my vote of 5
Another great answer for a more complicated but customisable solution.

Thanks a lot !

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900