I have 2 pages
page 1 contains an asp button which should call a code behind function then open the page2 as a popup window
on page2 there is also an asp button which should call a function from its own code behind and another function from page1 code behind then close the popup window
in other words: I need to transfer data from page1 to page2, and prepare another data in page2 before closing and inform page1 about closing to receive the data
note: I want to do this without user permission for the popup, so registering scripts from code behind? not what I am looking for!
"I use sessions to transfer data"
What I have tried:
I tried to call an invisible asp buttons click event using javascript
It works in page1 but not always
"page1 using master page"
"page2 webform"
At this code I used
document.getElementById('ContentPlaceHolder1_HiddenButton').click();
in page1 to create the data session before opening the popup. and used
document.getElementById('HiddenButton').click();
in page2 to prepare another data session for return. also used
opener.document.getElementById('ContentPlaceHolder1_HiddenButton1').click();
in page2 to inform page1 about new data session and popup closing.
page1 code
<script type="text/jscript">
function OpenPopup() {
document.getElementById('ContentPlaceHolder1_HiddenButton').click();
window.open("WebForm1.aspx", "List", "scrollbars=yes,resizable=no,width=1000,height=600");
return false;
}
</script>
<asp:Button ID="HiddenButton1" runat="server" Text="Button" style="display:none"
OnClick="HiddenButton1_Click"/>
<asp:Button ID="HiddenButton" runat="server" Text="Button" style="display:none" OnClick="HiddenButton_Click"/>
<asp:Button ID="btnOffer" runat="server" Text="Add Offer" onclientclick="javascript:return OpenPopup();"/>
page2 code
<script type="text/javascript">
function returnValues() {
document.getElementById('HiddenButton').click();
opener.document.getElementById('ContentPlaceHolder1_HiddenButton1').click();
window.close();
}
</script>
<asp:Button ID="HiddenButton" runat="server" Text="Button" style="display:none" OnClick="HiddenButton_Click"/>
<asp:Button ID="btnFinish" runat="server" OnClientClick="javascript:return returnValues()" Text="finish and close" />