Re: How to open a new window then close it but retain session?

Discussion in 'ASP .Net' started by Alexey Smirnov, May 21, 2010.

  1. On May 21, 6:49 pm, MWulfe <> wrote:
    > I want to open a new browser window from my main page from a button
    > click event while retaining all the session variables, but I have a
    > few other requirements:
    >
    > 1.  Before the main window closes, I want to check that spefic text
    > boxes and dropdowns have been filled in.  If not, i want to display an
    > alert, which I am doing with a js script and keep the main page
    > displayed.
    >
    > 2.  Before the main window closes I want to set a bunch of session
    > variables based on what was entered in the main window, for use in the
    > new window.
    >
    > 3.  When closing the new window, I would like there to be no
    > confirmation window displayed, and i want to keep the session
    > variables' values.
    >
    > Any ideas?


    Why do you need to close window, when user still remain on the site?
    If window was not opened via javascript, you cannot close it without
    client prompt, if I'm not wrong. It means that this will not probably
    work as you expected and it will be much easy not to close any window
    automatically.
     
    Alexey Smirnov, May 21, 2010
    #1
    1. Advertising

  2. On May 21, 9:43 pm, MWulfe <> wrote:
    > On Fri, 21 May 2010 11:36:01 -0700 (PDT), Alexey Smirnov
    >
    >
    >
    >
    >
    > <> wrote:
    > >On May 21, 6:49 pm, MWulfe <> wrote:
    > >> I want to open a new browser window from my main page from a button
    > >> click event while retaining all the session variables, but I have a
    > >> few other requirements:

    >
    > >> 1.  Before the main window closes, I want to check that spefic text
    > >> boxes and dropdowns have been filled in.  If not, i want to display an
    > >> alert, which I am doing with a js script and keep the main page
    > >> displayed.

    >
    > >> 2.  Before the main window closes I want to set a bunch of session
    > >> variables based on what was entered in the main window, for use in the
    > >> new window.

    >
    > >> 3.  When closing the new window, I would like there to be no
    > >> confirmation window displayed, and i want to keep the session
    > >> variables' values.

    >
    > >> Any ideas?

    >
    > >Why do you need to close window, when user still remain on the site?

    >
    > Because the main window is still open, and the user is still it.  It's
    > only the new window that needs to close.
    >
    > >If window was not opened via javascript, you cannot close it without
    > >client prompt, if I'm not wrong. It means that this will not probably
    > >work as you expected and it will be much easy not to close any window
    > >automatically.

    >
    > If I'm not wrong, the problem with opening a new window with js is
    > that the new window will not have access to the session variables from
    > the parent.


    If you are using a cookie-based session and you just open a new
    window, you'll share cookies, including the SessionID cookie and thus
    the same session. If you launch this new window in a separate process,
    then you will have a new session even for the same application.

    http://msdn.microsoft.com/en-us/magazine/cc163708.aspx

    Just try to output your session variables on the page to check how it
    would work.
     
    Alexey Smirnov, May 21, 2010
    #2
    1. Advertising

  3. On May 22, 5:06 pm, MWulfe <> wrote:
    > This does nor really answer my main questions.  
    >
    > I want to open a new window but only after executing code that (1)
    > checks current values in text boxes and dropdowns, preventing the new
    > window from opeing if certain conditions are unmet,  and (2) sets
    > severl session variables that are retained in the new window.
    >
    > It looks like I will not be able to do this with JS.  According to MS,
    > inhttp://msdn.microsoft.com/en-us/library/ms644696(VS.85).aspx,
    > "Opening a new window using JavaScript is not supported in Windows 7
    > and later. Instead, use a hyperlink with a target attribute equal to
    > _blank."
    >
    > On Fri, 21 May 2010 14:55:18 -0700 (PDT), Alexey Smirnov
    >
    >
    >
    > <> wrote:
    > >On May 21, 9:43 pm, MWulfe <> wrote:
    > >> On Fri, 21 May 2010 11:36:01 -0700 (PDT), Alexey Smirnov

    >
    > >> <> wrote:
    > >> >On May 21, 6:49 pm, MWulfe <> wrote:
    > >> >> I want to open a new browser window from my main page from a button
    > >> >> click event while retaining all the session variables, but I have a
    > >> >> few other requirements:

    >
    > >> >> 1.  Before the main window closes, I want to check that spefic text
    > >> >> boxes and dropdowns have been filled in.  If not, i want to display an
    > >> >> alert, which I am doing with a js script and keep the main page
    > >> >> displayed.

    >
    > >> >> 2.  Before the main window closes I want to set a bunch of session
    > >> >> variables based on what was entered in the main window, for use in the
    > >> >> new window.

    >
    > >> >> 3.  When closing the new window, I would like there to be no
    > >> >> confirmation window displayed, and i want to keep the session
    > >> >> variables' values.

    >
    > >> >> Any ideas?

    >
    > >> >Why do you need to close window, when user still remain on the site?

    >
    > >> Because the main window is still open, and the user is still it.  It's
    > >> only the new window that needs to close.

    >
    > >> >If window was not opened via javascript, you cannot close it without
    > >> >client prompt, if I'm not wrong. It means that this will not probably
    > >> >work as you expected and it will be much easy not to close any window
    > >> >automatically.

    >
    > >> If I'm not wrong, the problem with opening a new window with js is
    > >> that the new window will not have access to the session variables from
    > >> the parent.

    >
    > >If you are using a cookie-based session and you just open a new
    > >window, you'll share cookies, including the SessionID cookie and thus
    > >the same session. If you launch this new window in a separate process,
    > >then you will have a new session even for the same application.

    >
    > >http://msdn.microsoft.com/en-us/magazine/cc163708.aspx

    >
    > >Just try to output your session variables on the page to check how it
    > >would work.


    Nonsense... it's about Microsoft HTML Help 1.4 SDK

    You will be able to open a new window using javascript in Windows 7.
    Just do a test

    <script language="JScript">
    function myOpen() {
    open('http://msn.com');}
    </script>
    <body onload="myOpen();">
    Test
    </body>

    Of course, all browsers that have popup blockers, will block the new
    window from opening because of it's pop-up blocking feature.
     
    Alexey Smirnov, May 22, 2010
    #3
  4. On May 22, 8:31 pm, MWulfe <> wrote:
    > On Sat, 22 May 2010 08:52:24 -0700 (PDT), Alexey Smirnov
    >
    >
    >
    >
    >
    > <> wrote:
    > >On May 22, 5:06 pm, MWulfe <> wrote:
    > >> This does nor really answer my main questions.  

    >
    > >> I want to open a new window but only after executing code that (1)
    > >> checks current values in text boxes and dropdowns, preventing the new
    > >> window from opeing if certain conditions are unmet,  and (2) sets
    > >> severl session variables that are retained in the new window.

    >
    > >> It looks like I will not be able to do this with JS.  According to MS,
    > >> inhttp://msdn.microsoft.com/en-us/library/ms644696(VS.85).aspx,
    > >> "Opening a new window using JavaScript is not supported in Windows 7
    > >> and later. Instead, use a hyperlink with a target attribute equal to
    > >> _blank."

    >
    > >> On Fri, 21 May 2010 14:55:18 -0700 (PDT), Alexey Smirnov

    >
    > >> <> wrote:
    > >> >On May 21, 9:43 pm, MWulfe <> wrote:
    > >> >> On Fri, 21 May 2010 11:36:01 -0700 (PDT), Alexey Smirnov

    >
    > >> >> <> wrote:
    > >> >> >On May 21, 6:49 pm, MWulfe <> wrote:
    > >> >> >> I want to open a new browser window from my main page from a button
    > >> >> >> click event while retaining all the session variables, but I have a
    > >> >> >> few other requirements:

    >
    > >> >> >> 1.  Before the main window closes, I want to check that spefic text
    > >> >> >> boxes and dropdowns have been filled in.  If not, i want to display an
    > >> >> >> alert, which I am doing with a js script and keep the main page
    > >> >> >> displayed.

    >
    > >> >> >> 2.  Before the main window closes I want to set a bunch of session
    > >> >> >> variables based on what was entered in the main window, for use in the
    > >> >> >> new window.

    >
    > >> >> >> 3.  When closing the new window, I would like there to be no
    > >> >> >> confirmation window displayed, and i want to keep the session
    > >> >> >> variables' values.

    >
    > >> >> >> Any ideas?

    >
    > >> >> >Why do you need to close window, when user still remain on the site?

    >
    > >> >> Because the main window is still open, and the user is still it.  It's
    > >> >> only the new window that needs to close.

    >
    > >> >> >If window was not opened via javascript, you cannot close it without
    > >> >> >client prompt, if I'm not wrong. It means that this will not probably
    > >> >> >work as you expected and it will be much easy not to close any window
    > >> >> >automatically.

    >
    > >> >> If I'm not wrong, the problem with opening a new window with js is
    > >> >> that the new window will not have access to the session variables from
    > >> >> the parent.

    >
    > >> >If you are using a cookie-based session and you just open a new
    > >> >window, you'll share cookies, including the SessionID cookie and thus
    > >> >the same session. If you launch this new window in a separate process,
    > >> >then you will have a new session even for the same application.

    >
    > >> >http://msdn.microsoft.com/en-us/magazine/cc163708.aspx

    >
    > >> >Just try to output your session variables on the page to check how it
    > >> >would work.

    >
    > >Nonsense... it's about Microsoft HTML Help 1.4 SDK

    >
    > >You will be able to open a new window using javascript in Windows 7.
    > >Just do a test

    >
    > ><script language="JScript">
    > >function myOpen() {
    > >    open('http://msn.com');}
    > ></script>
    > ><body onload="myOpen();">
    > >Test
    > ></body>

    >
    > >Of course, all browsers that have popup blockers, will block the new
    > >window from opening because of it's pop-up blocking feature.

    >
    > Nonsense it is, you got it right.  Thanks!!


    Glad if it helps.

    Thought you might be interesting in Popup/ModalPopup Ajax Controls
    from the ASP.NET AJAX Control Toolkit
    http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/ModalPopup/ModalPopup.aspx
     
    Alexey Smirnov, May 26, 2010
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    343
  2. john
    Replies:
    2
    Views:
    244
    Bob Barrows [MVP]
    Jan 30, 2006
  3. Shang Wenbin

    close current window using window.close()

    Shang Wenbin, Sep 1, 2005, in forum: Javascript
    Replies:
    10
    Views:
    427
    Gérard Talbot
    Sep 2, 2005
  4. Navillus
    Replies:
    7
    Views:
    266
    Randy Webb
    May 23, 2006
  5. Iulian Ilea
    Replies:
    1
    Views:
    347
    pcx99
    Dec 21, 2006
Loading...

Share This Page