Solved

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

Posted on 2006-11-30
5
261 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 18045494
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
ID: 18045531
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 18

Accepted Solution

by:
Elvio Lujan earned 125 total points
ID: 18045575
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
ID: 18045588
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
ID: 18045780
I ended up using

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


Thanks guys.

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

688 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