Solved

ASP.NET  (closing popup window & passing session variable)

Posted on 2004-03-25
2
1,256 Views
Last Modified: 2012-05-04




I have an .aspx page (main.aspx) with a button that opens up a popup window (popup.aspx) using the code below.

Private Sub btnOK_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnOK.Click

            Dim popupScript As String = "<script language='javascript'>" & _
             "window.open('popup.aspx', 'CustomPopUp', " & _
             "'width=640, height=470, menubar=no, resizable=no, scrollbars=no')" & _
             "</script>"
            RegisterStartupScript("PopupScript", popupScript)
End Sub

Here is my question.

The popup window is a survey where the user answers some questions. (True/False & multiple choice). I have some code that builds a string of characters based upon the responses. String consists of 1's, 2's 3's, & 4's and is held in a session variable.

When the survey is complete, I would like to close window (popup.aspx) and pass this session variable back to (main.aspx).

Any suggestions or answers on the best way to do this?

Thanks,
Mike
0
Comment
Question by:MichaelVB
2 Comments
 
LVL 35

Accepted Solution

by:
YZlat earned 500 total points
ID: 10682729
this javascript function will close your popup window and load parent window again:

function loadinparent(url, closeSelf){
      self.opener.location = url;
      if(closeSelf) self.close();
      }

put this function in the <head> section of the page of your popup window.

Put a button on your popup page that will close it:
<asp:Button id="myButton" text="Close Me" runat="server" />

Then in Page_Load procedure put the following code:

myButton.Attributes.Add("onclick", "javascript:loadparent('main.aspx'), this);")

0
 

Author Comment

by:MichaelVB
ID: 10705960
YZlat,

Thanks for your help, for some reason this is not working though.

// This is what I have in page OnScreen2.aspx which is the PopUp window:

<HTML>
  <HEAD>
    <title>Test Presentation</title>
   
    <SCRIPT language="javascript">
      function loadinparent(url, closeSelf)
      {
       self.opener.location = url;
       if(closeSelf)self.close();
      }
     </SCRIPT>
</HEAD>

In the body I have:
<ASP:BUTTON id="btnSSupervisor" runat="server" text="Supervisor"></ASP:BUTTON>

In codeBehind page (OnScreen2.aspx.vb) I have this

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    btnESupervisor.Attributes.Add("onclick", "javascript:loadinparent('OnScreen.aspx'), this);")
    ' actual code automatically underlines     _______________________________________  this part here
End Sub

// OnScreen.aspx is the main window that opens the PopUp window...

The only thing that seems to  happen when I click on btnESupervisor is the screen refreshes but nothing else?
Any ideas on what I may be doing wrong here?

Thanks again,
Mike
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Leverage browser caching 2 55
Calculating value of records from a column - classic asp 7 67
Select2 jquery help 9 74
Classic ASP - problem with MS SQL Select Query? 10 57
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

948 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

23 Experts available now in Live!

Get 1:1 Help Now