formView Hangs

Last post 05-08-2008 12:34 PM by Gaset. 3 replies.

Sort Posts:

  • formView Hangs

    01-03-2007, 2:54 PM
    • Loading...
    • nealy303
    • Joined on 12-19-2006, 8:43 PM
    • Posts 8

    I am having trouble isolating and fixing the cause of a hang, freeze, or locking form that fails to load correctly after the third go.

    There are several conditions that must exists for this to take place.

    1. Using Ajax UpdatePanel with a formview inside the UpdatePanel, create a web form called formViewForm.aspx. (I like how the user does not see the page reload and believes the form is live!)
    2. The data source is created using the SQLAdapter connecting to a three column table in SQL Server 2000 (using the SQL commands built into the SQLAdapter, nothing special).
    3. Place a ASP.net server control button on the item panel, label it CloseButton, text=Close, and OnClientClick="window.close()"
    4. create another form and place another ASP.net server control button on the page, anywhere. Set the name = OpenButton, the Text = "Open", and the OnClientClick="window.open(formViewForm.aspx,"EditForm",formFeatures); f(ormfeatures control what features are active, like menubar, toolbar, statusbar, height and width, etc.)
    5. Set the new form as the default form and run the debug.

    Press the Open button, and the formviewform opens fine. Press the close button and the form closes fine. Repeat this again and all is still fine. press the open button one more time and the formview never fully opens, just hangs with the url in the title bar and blank everywhere.

     If I close both forms and try to run it again in a big hurry (like real world people do) then I get a severe error and have to restart VisualStudio 2005 to remedy the problem.

     If you repeat the above procedure of open and close and instead of using the close button, close the form using the window close (X) button in the upper right corner, then there is no problem.

     So the problem lies with the window.close() command.

     Any one seen this before or have a fix or way to figure out what else must be done to ensure a clean close so nothing inteferes with opening?

     

  • Re: formView Hangs

    01-03-2007, 4:52 PM
    • Loading...
    • nealy303
    • Joined on 12-19-2006, 8:43 PM
    • Posts 8

    Me again. I have done some more playing around and have discovered that if I replace the "Close" server button with an HTML input button, called "CloseButton", value = "Close", double click the button to get an OnClick function and enter "window.close();" in the function, the problem vanishes for this button. The form no longer hangs after multiple calls.

     However, I still use server controls that call the window.close feature. I have replaced the built in delete button with a server button entitled Delete and want the form to close after the delete is pressed (since the data is gone!) and I will still get the hang if the user does this more than two times.

     I have also discovered that if the server controls are outside the AJAX updatepanel, then the problem goes away. However, I need these buttons on the various views of the formview control, which is inside the updatepanel, so I am still a little stuck.

  • Re: formView Hangs

    03-21-2007, 7:57 PM
    Answer
    • Loading...
    • bjwood
    • Joined on 11-04-2006, 5:57 PM
    • Posts 4

    I just had the same issue.  I solved it by returning false from the script code that closes the window:

     Javascipt on page:

    function fnClose() {

       window.close();

       return false;

    }

    In my code behind:

    Me

    .btnCancel.Attributes.Add("onclick", "return fnClose();")

    This worked every time and you can leave your buttons inside the update panel.

     

    Hope it helps

  • Re: formView Hangs

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

     I just had the same problem. But peculiarity is that I needed to execute server-side code.

     

    Solution is as follows: user server control and in register close script in the event handler just like this:

     

    ScriptManager.RegisterStartupScript(this, sender.GetType(), "Close", "window.close()", true);
     

     
Page 1 of 1 (4 items)