refreshing parent window on closing of child window

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • svibuk
    New Member
    • Dec 2008
    • 8

    refreshing parent window on closing of child window

    i have page1.aspx with a grid and ADD button
    when i click ADD page2.aspx opens in a new window
    when new records an be added

    when i save the record it gets added to database as well as page2.aspx closes
    wht i need is when page2.aspx closes page1.aspx shld get refeshed and the new added record dispalyed in grid

    i have the following code
    Code:
    Dim strscript As String = "<script language=javascript>refreshandclose();</script>"
    If (Not Page.IsStartupScriptRegistered("clientScript")) Then
     Page.RegisterStartupScript("clientScript", strscript)
    End If
    -- now on the html
    Code:
    <head>
    <script language='javascripts'>
     function refreshandclose()
     { 
      window.top.parent.location = 'parent.aspx';
      window.setTimeout('window.top.close();', 1000);
     }
    </script>
    </head>
    Last edited by Frinavale; Dec 17 '09, 08:25 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.
  • semomaniz
    Recognized Expert New Member
    • Oct 2007
    • 210

    #2
    Please read

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      I ran into a few problems with this when using FireFox (version 2).
      See my problem and solution in this thread:


      -Frinny

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Svibuk, your script tag is invalid.
        It should be:
        Code:
        <script type="text/javascript">
        </script>
        That's not what your problem is.
        In fact I'm not really sure what your problem is....

        A couple of pieces of advise I can give you is to give your child window a name when you open it...otherwise you're going to have problems accessing the JavaScript method in the parent browser when the child browser closes.

        The other thing I recommend is putting an invisible ASP.NET control (like a LinkButton or Button control with the style of display:none) on the page. When you want to refresh the browser use JavaScript to submit the page using the control.

        This way you can handle the Button/LinkButton event and in your server side code to refresh the GridView. You know that the page has been submitted because the child browser has been closed because this button is not visible/accessible to the user.

        You don't have to submit the page using the ASP.Net control..you could refresh the GridView in your Page Load event every time. This just let's you be more specific.

        -Frinny

        Comment

        Working...