Solved

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

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

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…
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…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

785 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