akosch
akosch

Reputation: 4406

How do I close a popup window on a press of a button and initiate postback on the window opening the popup?

see above...

Upvotes: 1

Views: 2677

Answers (4)

Amrik
Amrik

Reputation: 456

string windowArgs = "toolbar=no,menubar=no,location=no,width=620,height=500,scrollbars=yes,resizable=yes,modal=yes"; string newWindowUrl = "MarketShotPreview.aspx"; string javaScript = "\n" + "\n" + "\n"; ClientScript.RegisterStartupScript(typeof(System.Web.UI.Page), "Popup", javaScript);

Upvotes: 0

cgreeno
cgreeno

Reputation: 32391

I would do something like so in button click of the popup

ClientScript.RegisterStartupScript(typeof(string), "auto_refreshparent", @" window.opener.location.reload(); ", true);
ClientScript.RegisterStartupScript(typeof(Page), "ThatsAllFolks", "window.close();", true);

Upvotes: 2

Joel
Joel

Reputation: 19368

You should be able to call functions in window.parent.

<script type="text/javascript">
    function closeThisPopupWindow()
    {
        if (window.parent && window.parent.callBack)
            window.parent.callBack();
        window.close();
    }
</script>

Obviously you would need to attach the closeThisPopupWindow function to your button.

Upvotes: 3

Chris Van Opstal
Chris Van Opstal

Reputation: 37567

Try something like this:

parent.document.getElementById('btnSubmit').click();; // submit the parent form
self.close(); // close the current window

Upvotes: 2

Related Questions