Solved

transferring values from the pop-up window to the parent window

Posted on 2006-11-30
5
257 Views
Last Modified: 2008-02-01
I have an asp.net page that opens a new window. The user selects some options in that new window and clicks Apply button. I need to transfer the values from the pop-up window to the main window and reload the main window to enable it to use the values from a pop-up window. What's the best way to do that?

I created global variables that are accessible by any page and assigned the values to those variables in the code-behind of the pop-up window. Now how do I reload main window to use those values?
0
Comment
Question by:YZlat
  • 2
  • 2
5 Comments
 
LVL 43

Expert Comment

by:TimCottee
Comment Utility
Hi YZlat,

The easiest way is actually to use javascript to directly write the values back to the main page: for example you could have a button in the popup

<input type=button id="UpdMainPage" value="Update Main Page" onclick="updateValues();">

And some script in the popup that does:

function updateValues()
{
    var parent=window.opener.document;
    parent.getElementById('Field1').value = document.getElementById('Field1');
// and so on for all the values
    self.close(); //close the popup having transferred the values.
}

This way you don't necessarily need to reload the main page even!

Tim Cottee
0
 
LVL 35

Author Comment

by:YZlat
Comment Utility
Hi Tim. Thanks for the quick response. the thing is if I don't reload the main page, how will it use the new values?

also I do not pass the value of a control to another control on the parent page, but instead pass a string variable from pop-up to the parent page.

So I figured after assigning the values to the global variable I just reload the parent page. How would I do that using C# (after assigning values to a string variable)?
0
 
LVL 17

Accepted Solution

by:
lem2802 earned 125 total points
Comment Utility
add the submit() to your submit button:

btn.Attributes.Add("onclick", "window.opener.document.forms[0].submit(); window.close();");
0
 
LVL 43

Assisted Solution

by:TimCottee
TimCottee earned 125 total points
Comment Utility
YZlat,

If by global variables you mean client-side javascript or vbscript variables then you would just use:

window.opener.location.href=window.opener.location.href

Setting the page location of the calling window to the same location will reload that page. If these are application global variables, the same applies really as long as you have posted them in the popup page. You could on postback clear the response so that no content is displayed in the popup and use

Response.Write ("<script language=javascript type=text/javascript>window.opener.location.href=window.opener.location.href;self.close();</script>");

To output the script, it will force the reload of the parent page and close the popup in one go.



Tim
0
 
LVL 35

Author Comment

by:YZlat
Comment Utility
I ended up using

Response.Write("<script language='JavaScript'>window.opener.location.reload();</script>")


Thanks guys.

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now