0

I got one classic asp page and another aspx page. The classic asp page will be the parent page and the aspx page will be the child page. The child page will have a code behind page that update or add the data. The changes after any operation (update/add) will be reflected immediately at the parent page, after the child close via window.close().

I have tried to set hidden variable at the parent page and set the hidden variable at the child page and put it at body onunload event, but it seems not working.

My classic asp page:

if Request.Form="" then
  if Request.Form("hidMode") = "Cr" and Request.Form("hidECardID") <> "" then
    SuccessMsg  = "The ECard ID template is successfully created."
  end if
end if

At end of classic asp page (before form tag closing):

<input type="hidden" name="hidMode">
<input type="hidden" name="hidECardID">

My aspx page:

inside head tag:

<script type="text/javascript">
function passVal() {
    winObj = window.opener
    //alert(window.opener.location.href) //doesn't produce popup
    eCardID =<%=hdECardID.Value%>
    docMode =<%=hdMode1.Value%>
    winObj.document.form1.hidECardID.value = eCardID;
    winObj.document.form1.hidMode.value = docMode;
    window.opener.document.form1.submit();
    window.close()
}
</script>

At body tag:

<body onunload="passVal()"> 

I've search for answer but mostly is aspx to aspx page. I could use response.redirect, but my issue is this aspx is a pop-up (not an iframe), after user clicked on a button on the classic asp page. Using response.redirect will only open the page inside the pop-up itself, and not refreshing the parent page.

  • 1
    Does this answer your question? [how to pass a value from iframe to the parent?](https://stackoverflow.com/questions/32328679/how-to-pass-a-value-from-iframe-to-the-parent). The `postMessage()` function should still work in a popup as well as an iframe. The issue is [cross-document](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage) and how browsers are becoming more and more strict about what can be passed between them. – user692942 Jul 05 '21 at 14:34
  • I assume `eCardID =<%=hdECardID.Value%>` and `docMode =<%=hdMode1.Value%>` in your aspx page throws a NullReferenceException ? The aspx page won't know what `hdECardID` and `hdMode1` are in the way you're using them. They should be in the Request.Form collection, have you tried that ? – sh1rts Jul 06 '21 at 00:25

0 Answers0