Solved

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

Posted on 2004-03-25
2
1,252 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
Comment Utility
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
Comment Utility
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

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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/…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 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