[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2006-11-30
5
Medium Priority
?
264 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 500 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 500 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

Technology Partners: 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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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 …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

649 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