Window hangs on the third openning

Last post 05-09-2008 3:26 AM by Gaset. 5 replies.

Sort Posts:

  • Window hangs on the third openning

    05-08-2008, 12:25 PM
    • Loading...
    • Gaset
    • Joined on 07-19-2005, 4:22 AM
    • Posts 62

     Hello,

     

    I have exactly the same problem as described here. The only reason is that I need to execute server-side code when close button is clicked.

     

    Solution is needed urgently, because the project is needed to be presented to public audience next week. Any help will be appreciated! 

  • Re: Window hangs on the third openning

    05-08-2008, 12:39 PM
    • Loading...
    • Gaset
    • Joined on 07-19-2005, 4:22 AM
    • Posts 62

     Just found a solution : user server control and register close script in the event handler just like this:

     

    ScriptManager.RegisterStartupScript(this, sender.GetType(), "Close", "window.close()", true);
     
    PS It's a pity that AJAX has such bugs. 
     
    PPS I would like to know if there is a fix from Microsoft for this bug. 
  • Re: Window hangs on the third openning

    05-08-2008, 1:46 PM
    • Loading...
    • stmarti
    • Joined on 06-06-2006, 12:20 PM
    • Posts 542

    Hi,

    Ajax doesn't have such bug, this is a browser bug and bad code.

    Putting window.close in the onclick of a submit button is bad, because you break the async postback: the browser cannot handle the situation: browser bug.

    If you want to close without server side code, use a simple input element (type=button), you don't need an asp:button for this.

    If you want some server side code before closing your window, RegisterStartupScript is the (easiest) way, as you find out.

     

  • Re: Window hangs on the third openning

    05-08-2008, 3:00 PM
    • Loading...
    • Gaset
    • Joined on 07-19-2005, 4:22 AM
    • Posts 62

    Strange thing is that this is not documented anywhere. And it is regularly reproduced on the third (not the first...) request. But ok with this.

     

     What is the right (smartest) way to do this?

     

    PS And I do not really understand why this is browser that cannot process async request after it is closed. As I understand the instance of the browser is destroyed. Thus the result is not processed at all. Why should it be a problem?
     

  • Re: Window hangs on the third openning

    05-08-2008, 3:39 PM
    Answer
    • Loading...
    • stmarti
    • Joined on 06-06-2006, 12:20 PM
    • Posts 542

     I would stay with registerstartupscript, but you can use other events for closing the window (endRequest Event and a flag which indicates that the window should be closed): ASP.NET AJAX Client Life-Cycle Events

  • Re: Window hangs on the third openning

    05-09-2008, 3:26 AM
    • Loading...
    • Gaset
    • Joined on 07-19-2005, 4:22 AM
    • Posts 62

    Me too. The reason is that it is not obvious and there should be some kind of a filter in endRequest.

     

    Anyway thanks for ideas! 

Page 1 of 1 (6 items)