How Do I pass a parameter back to the parent page from child page when I refresh parent page

Latzi_Marian
Latzi_Marian used Ask the Experts™
on
I've read for two days solutions for the following question and tried dozens of solutions offered but none worked.So here's the problem.I am writing a ASP.NET application using CodeCharge  Studio.I have a .aspx page from where I do open a chile page with the following code:on the onclick event of the link I run   openwindow1();return true; where openwindow1() is in the HTML of the page and looks like this
       <script language="JavaScript1.2">
function openwindow1()
{
        window.open("http://localhost/NewProject98/Edit_Agency.aspx","mywindow","menubar=0,resizable=1,width=720,height=720");
}
</script>

Everything's good so far.
On the child window (Edit_Agency.aspx) I have a record form where user enters data and after the submit button is pushed the child window is closed and the parent is refreshed but unfortunately on the refresh I loose the variable I need to display the correct data.What I mean by this is when parent is loaded  from a different page an SQL query is run based on session variable varID1 and a single record is displayed.When I use refresh from the child that variable is gone and all records are displayed.However on the child page I do have the control which holds the right value I need to pass bachk to parent to run correct query.Child page code:
function refreshParent() {

window.opener.location.href = 'Agent_Details_Agency.aspx';

 if (window.opener.progressWindow)                
 {
  window.opener.progressWindow.close()
}
window.close();
}
</script>

My question here is if there is any way to do something like this in the code :
replace window.opener.location.href = 'Agent_Details_Agency.aspx'; with
window.opener.location.href = 'Agent_Details_Agency.aspx?varID1= ???????'
where the ??????? represents the code or syntax I need to use to refresh the parent page and pass the varID1= value (which I have in a textbx in the child form).I don't know if I was explicit enough I hope yes.
Any help would be greatly appreciated.

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
i suggest Dont do a href rather submit the parent page after setting the variable to some hidden field of the parent page.

function refreshParent() {

 if (window.opener.progressWindow)                
 {
  window.opener.progressWindow.close()
}
window.opener.document.forms[0].action = 'Agent_Details_Agency.aspx';
window.opener.document.forms[0].submit();
window.close();
}
</script>

please change teh forms[0] with the form name of the parent page. Also before the submit, i guess the variable is already set in the hidden field or any control field of parent form, so on the parent form, just get that value by saying request.form("variable") and you will get that value.

Commented:
well... this can be done exactly as you describe ;)
before window.close() add
window.opener.location.href = 'Agent_Details_Agency.aspx?varID1= ' + document.getElementById('some_id').value;

where some_id is an id of text field in your popup.
Latzi_MarianSystems Integrator

Author

Commented:
Thanx for the warp speed reply.I've tried araim's solution and I am almost there however this time when I push submit on the child page I do close the child and passthe parameter to the parent (in explorer address bar I have http://localhost/NewProject98/Agent_Details_Agency.aspx?varID1=3 which is perfect but it looks like the page doesn't refresh.I still have to push the refresh button on explorer to get the grid populated with the record corresponding to varID1=3.
So my code this time look like :
<script language="JavaScript">
function refreshParent() {
 
window.opener.location.href = 'Agent_Details_Agency.aspx?varID1=' + document.getElementById('Real_Estate_Agency1TextBox1').value;
 
// if (window.opener.progressWindow)
               
 //{
  //  window.opener.progressWindow.close()
  //}
  //window.close();
}

</script>

If I use
window.opener.location.href = 'Agent_Details_Agency.aspx' then the page refreshes but as I said because I loose varID1 I have the grid populated with hundredhs of records which is no good.Any Ideea what can be wrong??
I will also look into what asvforce said as well however I did look into araims solution as that one was closer to what I thought I should use .Any help greatly appreciated I really ahve to solve this tonight it is 11.30 p.m. already and I am still nowhere with it so I keep trying.Thank you again guys.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Commented:
you may try to force refresh :

window.opener.location.href = 'Agent_Details_Agency.aspx?varID1=' + document.getElementById('Real_Estate_Agency1TextBox1').value;

window.opener.location.reload(true);
Latzi_MarianSystems Integrator

Author

Commented:
Shall I delay the refreshParent function execution ?
Latzi_MarianSystems Integrator

Author

Commented:
Perfect. Problem solved once and forever.Thank you for your help araim .This place(experts exchange) I signed up tonight it's simply perfect.Thank you again
Latzi_MarianSystems Integrator

Author

Commented:
Sorry I've accepted a solution as a complete solution but actually I just saw after a few tests that the parent reloads only if I click the submit button twice and the child doesn't close anymore.However it worked the first time I tried your last suggestion by adding window.opener.location.reload(true);
Since then I still try to do something with it it's still not 100%

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial