Keeping RadWindow Closed When Closed!

3 posts, 0 answers
  1. Sean
    Sean avatar
    200 posts
    Member since:
    Nov 2010

    Posted 29 Aug 2011 Link to this post

    Hi Telerik,

    As a disclaimer, this question is vague. My issue is that, under certain conditions, a RadWindow will re-open itself and become non-responsive to user interaction. For instance, if I have some client-side code which is executing (may or may not center the RadWindow), and the user closes the window before this code finishes executing. Then, when the code finishes executing, the window pops back open! If the user clicks on the 'X' it does not close the window.

    I suspect this is entirely my fault... possibly should not allow closing of the window until fully loaded, or find a way to cancel client-side script execution. Regardless, I was looking for a blanket fix to make sure this problem doesn't accidentally rear its head to a customer.

    At this point, I'm doing something like this:

    //This will only trigger when the browser window resizes.
    //Fix the display of the dashboard, if theres an open window, re-center it.
    function OnMainSplitterResizing() {
        displayOverBaseID = baseSplitterID;
     
        if (oWindow && oWindow.isVisible) oWindow.center();
    }

    In this scenario, I handle the browser window resizing. If there is an open window, I would like to move it back to the center of the page. It is my impression that calling oWindow.center on an element which is defined, but not visible, is dangerous in that it may show the window again?

    Does what I'm doing make sense? Have you heard of other users experiencing similar issues / is there a standard way of handling this? Or is it just "code better and not defensively" and make sure that the state of my window is such that at any point in time, if its closed, it can respond intuitively.

    Cheers,

    Sean
  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 31 Aug 2011 Link to this post

    Hello Sean,

    The only case where we have seen this issue is if the RadWindow is updated via an AJAX request while it is being loaded. What happens is that the HTML is created, but the disposing and reattaching of the events is interrupted by the markup update that comes with the AJAX response.

    That means that if you are using a RadWindow with a ContentTemplate, a button inside initiates an AJAX request and the entire RadWindow is wrapped in the update panel this behavior may be observed. To avoid this you should properly ajaxify the RadWindow, as explained in this help article (i.e. keep the update panels inside the ContentTemplate).

    If that is not the case in your scenario I am not sure what may be causing this, but it should be related to an incorrect disposing of the RadWindow object.

    As for calling the center() method of a RadWindow that is not shown - indeed this should not be done, so your check is in place and I do not believe this is the cause of the issue, yet you may test if removing it resolves the situation and does not break the RadWindow somehow. If so - go without it.

    Kind regards,
    Marin
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sean
    Sean avatar
    200 posts
    Member since:
    Nov 2010

    Posted 06 Sep 2011 Link to this post

    Hi Telerik,

    Thank you for your informative response. I will keep these concepts in mind for future programming endeavors. Regarding my issue, I did find a solution, but I am not quite sure why the solution worked. I'll just provide the scenario / fix in case anyone experiences this problem in the future.

    Scenario: RadWindow re-opens itself upon centering.
    Setup:
    <telerik:RadWindow ID="ReportWindow" Runat="Server" Title="CableSolve Report Viewer" Width="600" Height="500" />

    This is how my RadWindow is declared. This window is opened off of a RadDock's custom command by firing client-side code:

    //Opens the Custom Report Viewer window using the dock's reportID as a parameter to display appropriate data.
    function OpenReport(dock) {
        var fullURL = window.reportViewerURL + dock.get_element().getAttribute("ReportID");
        oWindow = window.radopen(fullURL, "ReportWindow");
    }

    The URL points to an MVC page on our web application.

    Now, with the above code, if the window is opened, closed, and then this method is executed:

    //This will only trigger when the browser window resizes.
    //Fix the display of the dashboard, if theres an open window, re-center it.
    function OnMainSplitterResizing() {
        displayOverBaseID = baseSplitterID;
        if (oWindow && oWindow.isVisible) oWindow.center();
    }

    Even though the window has been closed, this state information is not written back to the oWindow variable (presumed by me). As such, the seemingly fail-safe code "oWindow && oWindow.isVisible" fails to fend-off this undesireable scenario.

    Solution:

    <telerik:RadWindow ID="ReportWindow" Runat="Server" Title="CableSolve Report Viewer" Width="600" Height="500" OnClientClose="OnReportWindowClose" />

    function OnReportWindowClose(dialogWindow) {
        oWindow = null;
    }

    This allows us to still maintain a reference to our open window (in case it needs to be re-centered), but also prevents the window from being made visible after previously being invisible.

    Cheers,

    Sean
Back to Top