0

I have two web page and one user control pages in my .aspx project.

Main.aspx

Controls/MiddlePage.ascx

FileUpload.aspx

I click a javascript link to open a popup window (FileUpload.aspx) in Controls/MiddlePage.ascx (embedded in Main.aspx) for loading an image. When an image has been uploaded successfully, I want to close popup automatically and want to carry image details to Main.aspx page automatically. How can I do this?

Can you help me please?

Thank you.

1 Answers1

0

In the popup in the postback after the file has been successfully uploaded render the following js code that should close it

<body onload="window.close();">

If you want to return a value to the parent page, you can add an input control that can be hidden and set its value from popup before it will be closed

<script type="text/javascript">
function closeme()
{
    window.opener.document.getElementById("InputImageName").value="<%#ImageName%>";
    window.close();
}
</script>
...
<body onload="closeme();">

where InputImageName is a control on parent page

<input type="text" id="InputImageName" />

and ImageName is a server variable that you define in the code behind during upload.

UPDATE

To refresh parent window, you can use reload() or specify new url for window.opener.location. Example:

window.opener.location.reload();
window.opener.document.location.href = url;

See Open popup and refresh parent page on close popup

Community
  • 1
  • 1
user2316116
  • 6,726
  • 1
  • 21
  • 35
  • It says: "Inaccessible due to level of protection" whether I changed class properties from Protected to Public –  Jan 11 '17 at 17:56
  • Actually, I managed to close popup, and carry image details to Controls/MiddlePage.ascx but I cannot refresh Main.aspx page automatically when popup closed. It shows me Controls/MiddlePage.ascx page on Main.aspx page. I just want to show Main.aspx with refreshed datas. That's it. Thanks. –  Jan 11 '17 at 18:10