Solved

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

Posted on 2004-03-25
2
1,268 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
[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 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

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