There is Code Snippets for Retrieve value from popup window on the parent window. Let us two page 1. Default1 with one textbox (txt1) and one button(btn1) 2. Default2 with one textbox(txt2) and one button(btn2)
Aim: Open the popup window(default2) and enter the value in txt2 of default2 then click on the btn2, it closed the popup window and value of txt2 send to the txt1 of default1 page through java script...
First of all write javascript for open default2.aspx as popup window
write on default1.aspx page
<script type="text/javascript">
//Funtion of open contact window as popup window function openwin() { window.open('default2.aspx','popuppage','scrollbars=no,width=400,height=400,resizable=no,left=500,top=260,toolbar=no,titlebar=no') }
</script>
Code for btn1 on default1.aspx.(which is open the popup window on click)
<asp:Button ID="btn1" runat="server" CausesValidation="False" OnClientClick="openwin(); return false;" TabIndex="13"> Go to default2 </asp:Button>
It open the default2.aspx page as popup window on click on btn1. Write a javascript for passing value from default2.aspx to default1.aspx
on default2.aspx page.
If you use content place holder then write this javascript code.
<script language="javascript" type="text/javascript">
function passValues() { window.opener.document.getElementById('ctl00_cph1_txt1').innerText = document.getElementById('<%=txt2.ClientID %>').value; }
</script>
if you not use content place holder then write this javascript code.
function passValues() { window.opener.document.getElementById('txt1').innerText = document.getElementById('<%=txt2.ClientID %>').value; } </script>
Code for btn2 on default2.aspx...(which close the popupwindow and send the value..)
<asp:Button ID="btn2" runat="server" CausesValidation="False" Text="Send Value" OnClientClick="passValues(); window.close()" TabIndex="5" />
Wen you enter any value in text box (txt2) and click on btn2 then default2.aspx popup window closed and value send on to txt1 of default1 page..
|
No responses found. Be the first to respond and make money from revenue sharing program.
|