Window.Opener Creating A Refresh In Parent Window

Discussion in 'ASP .Net' started by Steve Wark, Aug 29, 2004.

  1. Steve Wark

    Steve Wark Guest

    I have created a ASP.NET application and created two forms within the
    application (Webform1.aspx & Webform2.aspx). On the first form I have
    placed a textbox (TextBox1) and a button, which when clicked opens the
    second form using the window.open(). On the second form I have a textbox
    (TextBox1) and a button as well. When the second button is clicked it
    closes the second window with window.close(). What I need to happen is a
    refresh to happen on the original form so that the value passed back from
    the second window is displayed in the textbox.

    Webform1 Button Click Event
    Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles LinkButton1.Click

    Dim popupScript As String = "<script language='javascript'>" &
    "window.open('webform2.aspx', 'CustomPopUp', " & "'width=600, height=400,
    menubar=no, resizable=no, top=200, left=200')" & "</script>"

    Page.RegisterStartupScript("PopupScript", popupScript)

    End Sub



    Webform2 Button Click Event

    Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles LinkButton1.Click

    Dim popupScript As String = "<script language='javascript'>" &
    "window.opener.document.forms(0).value=" & Chr(34) & TextBox1.Text & Chr(34)
    & ";window.close();window.opener.location.href =
    window.opener.location.href" & "</script>"

    Page.RegisterStartupScript("PopupScript", popupScript)

    End Sub

    I have tried various options but none seem to work. Can anyone advise?



    Cheers

    Steve
     
    Steve Wark, Aug 29, 2004
    #1
    1. Advertisements

  2. On Sun, 29 Aug 2004 21:49:41 GMT, Steve Wark <>
    wrote:

    > I have created a ASP.NET application and created two forms within the
    > application (Webform1.aspx & Webform2.aspx). On the first form I have
    > placed a textbox (TextBox1) and a button, which when clicked opens the
    > second form using the window.open(). On the second form I have a textbox
    > (TextBox1) and a button as well. When the second button is clicked it
    > closes the second window with window.close(). What I need to happen is a
    > refresh to happen on the original form so that the value passed back from
    > the second window is displayed in the textbox.
    >
    > Webform1 Button Click Event
    > Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles LinkButton1.Click
    >
    > Dim popupScript As String = "<script language='javascript'>" &
    > "window.open('webform2.aspx', 'CustomPopUp', " & "'width=600, height=400,
    > menubar=no, resizable=no, top=200, left=200')" & "</script>"
    >
    > Page.RegisterStartupScript("PopupScript", popupScript)
    >
    > End Sub
    >
    >
    >
    > Webform2 Button Click Event
    >
    > Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles LinkButton1.Click
    >
    > Dim popupScript As String = "<script language='javascript'>" &
    > "window.opener.document.forms(0).value=" & Chr(34) & TextBox1.Text &
    > Chr(34)
    > & ";window.close();window.opener.location.href =
    > window.opener.location.href" & "</script>"
    >
    > Page.RegisterStartupScript("PopupScript", popupScript)
    >
    > End Sub
    >
    > I have tried various options but none seem to work. Can anyone advise?
    >
    >
    >
    > Cheers
    >
    > Steve
    >
    >
    >
    >



    you're closing the second window before refreshing the opener; closing the
    window stops the script right there, so the next line never runs. Switch
    those around, .close() is the last thing to do....

    btw, why do you need a refresh immediately? You can put the value back
    into the opener's textbox and not need to force a refresh....just FYI

    --
    Craig Deelsnyder
    Microsoft MVP - ASP/ASP.NET
     
    Craig Deelsnyder, Aug 29, 2004
    #2
    1. Advertisements

  3. Steve Wark

    Steve Wark Guest

    I tired you suggestion but it did not work, can you point me to a code
    snippet ?

    Steve

    "Craig Deelsnyder" <cdeelsny@no_spam_4_meyahoo.com> wrote in message
    news:eek:psdilfyin75dg5d@g51y101...
    > On Sun, 29 Aug 2004 21:49:41 GMT, Steve Wark <>
    > wrote:
    >
    > > I have created a ASP.NET application and created two forms within the
    > > application (Webform1.aspx & Webform2.aspx). On the first form I have
    > > placed a textbox (TextBox1) and a button, which when clicked opens the
    > > second form using the window.open(). On the second form I have a

    textbox
    > > (TextBox1) and a button as well. When the second button is clicked it
    > > closes the second window with window.close(). What I need to happen is

    a
    > > refresh to happen on the original form so that the value passed back

    from
    > > the second window is displayed in the textbox.
    > >
    > > Webform1 Button Click Event
    > > Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As
    > > System.EventArgs) Handles LinkButton1.Click
    > >
    > > Dim popupScript As String = "<script language='javascript'>" &
    > > "window.open('webform2.aspx', 'CustomPopUp', " & "'width=600,

    height=400,
    > > menubar=no, resizable=no, top=200, left=200')" & "</script>"
    > >
    > > Page.RegisterStartupScript("PopupScript", popupScript)
    > >
    > > End Sub
    > >
    > >
    > >
    > > Webform2 Button Click Event
    > >
    > > Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As
    > > System.EventArgs) Handles LinkButton1.Click
    > >
    > > Dim popupScript As String = "<script language='javascript'>" &
    > > "window.opener.document.forms(0).value=" & Chr(34) & TextBox1.Text &
    > > Chr(34)
    > > & ";window.close();window.opener.location.href =
    > > window.opener.location.href" & "</script>"
    > >
    > > Page.RegisterStartupScript("PopupScript", popupScript)
    > >
    > > End Sub
    > >
    > > I have tried various options but none seem to work. Can anyone advise?
    > >
    > >
    > >
    > > Cheers
    > >
    > > Steve
    > >
    > >
    > >
    > >

    >
    >
    > you're closing the second window before refreshing the opener; closing the
    > window stops the script right there, so the next line never runs. Switch
    > those around, .close() is the last thing to do....
    >
    > btw, why do you need a refresh immediately? You can put the value back
    > into the opener's textbox and not need to force a refresh....just FYI
    >
    > --
    > Craig Deelsnyder
    > Microsoft MVP - ASP/ASP.NET
     
    Steve Wark, Aug 30, 2004
    #3
  4. Steve Wark

    bruce barker Guest

    you have a couple problems:

    1) webform1 uses code that will not work with a popup blocker (say xp-sp2)
    2) webform1 close itsself before doing anything
    3) webform1 tries to update a textbox, but then forces a reload that will
    replace this value with tthe server version

    -- bruce (sqlwork.com)

    "Steve Wark" <> wrote in message
    news:xhMYc.13572$...
    > I tired you suggestion but it did not work, can you point me to a code
    > snippet ?
    >
    > Steve
    >
    > "Craig Deelsnyder" <cdeelsny@no_spam_4_meyahoo.com> wrote in message
    > news:eek:psdilfyin75dg5d@g51y101...
    > > On Sun, 29 Aug 2004 21:49:41 GMT, Steve Wark <>
    > > wrote:
    > >
    > > > I have created a ASP.NET application and created two forms within the
    > > > application (Webform1.aspx & Webform2.aspx). On the first form I have
    > > > placed a textbox (TextBox1) and a button, which when clicked opens the
    > > > second form using the window.open(). On the second form I have a

    > textbox
    > > > (TextBox1) and a button as well. When the second button is clicked it
    > > > closes the second window with window.close(). What I need to happen

    is
    > a
    > > > refresh to happen on the original form so that the value passed back

    > from
    > > > the second window is displayed in the textbox.
    > > >
    > > > Webform1 Button Click Event
    > > > Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e

    As
    > > > System.EventArgs) Handles LinkButton1.Click
    > > >
    > > > Dim popupScript As String = "<script language='javascript'>" &
    > > > "window.open('webform2.aspx', 'CustomPopUp', " & "'width=600,

    > height=400,
    > > > menubar=no, resizable=no, top=200, left=200')" & "</script>"
    > > >
    > > > Page.RegisterStartupScript("PopupScript", popupScript)
    > > >
    > > > End Sub
    > > >
    > > >
    > > >
    > > > Webform2 Button Click Event
    > > >
    > > > Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e

    As
    > > > System.EventArgs) Handles LinkButton1.Click
    > > >
    > > > Dim popupScript As String = "<script language='javascript'>" &
    > > > "window.opener.document.forms(0).value=" & Chr(34) & TextBox1.Text &
    > > > Chr(34)
    > > > & ";window.close();window.opener.location.href =
    > > > window.opener.location.href" & "</script>"
    > > >
    > > > Page.RegisterStartupScript("PopupScript", popupScript)
    > > >
    > > > End Sub
    > > >
    > > > I have tried various options but none seem to work. Can anyone

    advise?
    > > >
    > > >
    > > >
    > > > Cheers
    > > >
    > > > Steve
    > > >
    > > >
    > > >
    > > >

    > >
    > >
    > > you're closing the second window before refreshing the opener; closing

    the
    > > window stops the script right there, so the next line never runs.

    Switch
    > > those around, .close() is the last thing to do....
    > >
    > > btw, why do you need a refresh immediately? You can put the value back
    > > into the opener's textbox and not need to force a refresh....just FYI
    > >
    > > --
    > > Craig Deelsnyder
    > > Microsoft MVP - ASP/ASP.NET

    >
    >
     
    bruce barker, Oct 28, 2004
    #4
    1. Advertisements

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. Andrew Bewley via DotNetMonster.com

    window to window communication (window.opener)

    Andrew Bewley via DotNetMonster.com, Feb 3, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,294
    Andrew Bewley via DotNetMonster.com
    Feb 3, 2005
  2. Replies:
    2
    Views:
    804
    Nico VanHaaster
    Jun 8, 2006
  3. Urs Gubler
    Replies:
    0
    Views:
    308
    Urs Gubler
    Jul 2, 2003
  4. Yaron C.

    opener.opener ?

    Yaron C., Oct 30, 2003, in forum: Javascript
    Replies:
    4
    Views:
    384
    Yaron C.
    Nov 2, 2003
  5. PerryC
    Replies:
    28
    Views:
    782
    Ivan Marsh
    Jul 13, 2004
  6. Phil Powell
    Replies:
    4
    Views:
    314
    Dr John Stockton
    Feb 7, 2006
  7. Replies:
    3
    Views:
    212
    Erwin Moller
    Jun 22, 2006
  8. window.opener, form.opener?

    , Jul 14, 2006, in forum: Javascript
    Replies:
    5
    Views:
    496
Loading...