My RadWindow won't close!

19 posts, 1 answers
  1. Brian
    Brian avatar
    4 posts
    Member since:
    Mar 2009

    Posted 03 Apr 2009 Link to this post

    Okay, I've read and tried every approach on the forums about this (I think), so I PROMISE you this is my exhausted efforts causing me to post a probably pretty tired topic.

    Pretty simple: I have a page that is in a masterpage (not sure if thats important) with a link on it that opens a radwindow (I will put the code out below). That opens just fine. The page in the radwindow is a simple data-entry page, upon where I hit the "Save" button, it saves to the database, then closes the radwindow on postback. In the same radwindow, theres a cancel button that only calls the javascript to close the radwindow, and that works just fine. The code-behind that is supposed to close the window on postback just calls the same function that WORKS for the cancel button; the page posts back and the window re-opens, except its NOT modal (the initial window is modal) so the background is not greyed out, and its also twice the width it once was. Once the window has wrongfully reopened, the cancel button no longer works, and the save button just keeps posting back without closing.

    I've already tried double-checking that the javascript is firing on postback by putting in alerts.

    The link that opens the radwindow:
    <asp:LinkButton ID="lbAddPhone" runat="server" onclientclick="javascript:InsertPhone(); return false;">+ Phone/Email</asp:LinkButton> 


    InsertPhone()
    function InsertPhone() { 
            var hid = document.getElementById("<%= hidContactId.ClientID %>"); 
            var oWnd = $find("<%= wndAddPhone.ClientID %>"); 
            oWnd.setUrl("popup_addcontact.aspx?which=3&id=" + hid.value); 
            oWnd.show(); 
        } 

    Now for the popup_addcontact.aspx page:
    protected void btnPhoneSave_Click(object sender, EventArgs e) 
        { 
            string closingscript = "closeWin();"
            ScriptManager.RegisterStartupScript(thisthis.GetType(), "closeWin", closingscript, true); 
        } 

    closeWin()
    function closeWin() { 
                var wind = GetRadWindow(); 
                wind.close(); 
            } 
     
    function GetRadWindow() { 
                var oWindow = null
                 
                if (window.radWindow) { 
                    oWindow = window.radWindow; 
                } 
                else if (window.frameElement.radWindow) { 
                    oWindow = window.frameElement.radWindow; 
                } 
                 
                return oWindow; 
            } 

    If anyone has any insight, I'd greatly appreciate it. Like I said, I have confirmed that the javascript IS firing, and I have tried several different methods of code-behind injection, including putting a literal control on the host page.

    Thanks!
  2. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 06 Apr 2009 Link to this post

    Hello Brian,

    I prepared a test demo based on your code - I generated a new Date and appended it to the navigate url in order to mimic the query strings parameters you add.

    After I ran the sample I noticed the following:

    1.  When you open the radWindow for the very first time, it opens correctly but when you open it for next time, its size is different. This is caused by the fact that the status bar holds a very long url and a loading image is also shown there. The problem occurs only under IE due to a bug concerning this and it does not present under other browsers. In order to solve the issue, please set ShowContentDuringLoad="false" for the RadWindow - after I did this, the problem disappeared.
    2. I could not reproduce the problem with the RadWindow closure - it closes as expected.
    3. The Save and Cancel buttons work properly no matter the RadWindow is shown for first or next time and the javascript is correctly executed.

    For your convenience I attached the demo I prepared to test the reported issues - please examine it and in case you need further assistance, please modify my demo in order to replicate the issue, open a new support ticket and send it to me along with detailed explanations and reproduction steps.

    Sincerely yours,
    Svetlina
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Brian
    Brian avatar
    4 posts
    Member since:
    Mar 2009

    Posted 07 Apr 2009 Link to this post

    Thank you for your response. Your sample worked in my site, but as you said, you could not duplicate the problem; it still exists for me. Would a RadScriptManager in the masterpage be affecting anything? It seems there is also one in the popup_addcontact as well (in my solution, I mean).

    So it sort of looks like this:

    MasterPage (RadScriptManager1)
           >  Content Page (link to open the RadWindow)
    RadWindow (RadScriptManager2)

    Does that matter?

    Thanks again for your help.
  5. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 09 Apr 2009 Link to this post

    Hello Brian,

    Having MasterPage or RadScriptManager should not make difference and since I do not have your code I am unable to make further assumptions what might be causing the issue. This being said I believe that the best way to proceed is that you prepare a simple reproduction demo, open a new support ticket and send it to me along with detailed reproduction instructions and explanations. Once I receive it, I will debug it, find what is exactly happening and I will get back to you with a solution which you will be then able to include in your original project. 

    Greetings,
    Svetlina
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  6. Randy Skabelund
    Randy Skabelund avatar
    1 posts
    Member since:
    Mar 2009

    Posted 09 Apr 2009 Link to this post

    Brian,

    I'm fairly new at using the radwindow, but I was having the same issue as you are.  What I finally stumbled across was this property that seemed to work for me:

    DestroyOnClose=true 

    I am using a RadWindowManager and I set that proerty on it and my window will now close using a similar script as yours...

    good luck,

    -Randy

  7. Brian
    Brian avatar
    4 posts
    Member since:
    Mar 2009

    Posted 20 Apr 2009 Link to this post

    I still can't figure it out. I've tried a new approach. Heres my RadWindowManager:

    <telerik:RadWindowManager ID="rwmAddPhone" runat="server" Skin="Web20" Modal="True" VisibleStatusbar="False"  
                VisibleTitlebar="False" ReloadOnShow="True" ShowContentDuringLoad="False" KeepInScreenBounds="True"     
                AutoSize="True"
    </telerik:RadWindowManager> 

    Here is the button that activates the RadWindow:
    <asp:LinkButton ID="lbAddPhone" runat="server" OnClientClick="javascript:InsertPhone(); return false;">+ Phone/Email</asp:LinkButton> 

    And InsertPhone():
    function InsertPhone() { 
                var hid = document.getElementById("<%= hidContactId.ClientID %>"); 
                var oWindow = window.radopen("popup_addcontact.aspx?which=3&id=" + hid.value, null); 
            } 

    Here is what I use to close said RadWindow:
    protected void btnPhoneSave_Click(object sender, EventArgs e) 
         string closingscript = "closeWin();"
         ScriptManager.RegisterStartupScript(thisthis.GetType(), "closeWin", closingscript, true); 
    function GetRadWindow() { 
                var oWindow = null
                 
                if (window.radWindow) { 
                    oWindow = window.radWindow; 
                } 
                else if (window.frameElement.radWindow) { 
                    oWindow = window.frameElement.radWindow; 
                } 
                 
                return oWindow; 
            } 
            function closeWin() { 
                var wind = GetRadWindow(); 
                wind.close(); 
            } 



    Does anyone see anything strange?? I still can't close this thing.
  8. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 21 Apr 2009 Link to this post

    Hi Brian,

    I again tried to reproduce the issue but unfortunately to no avail - please see the attached new test demo. This being said, I believe that the best way to proceed is that you open a new support ticket and send me either mine modified demo or a new reproduction demo which will demonstrate the issue. Please, also include detailed reproduction steps and explanations along with the demo and make sure that it can be run without any modifications. Once I receive it, I will examine it locally and I will find and fix the issue.

    Greetings,
    Svetlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  9. Answer
    Greg
    Greg avatar
    17 posts
    Member since:
    Mar 2009

    Posted 24 Apr 2009 Link to this post

    I have just started using these controls and am experiencing the same issue. It is all related to setting AutoSize="true". If I leave that off, my window closes fine.

    To get around this, I have added this code:

            function openRadWindow(url) { 
                var manager = GetRadWindowManager(); 
                var modalWindow = manager.open(null"Edit Location"); 
                modalWindow.add_close(refreshLocationsGrid); 
                modalWindow.setUrl(url); 
     
                var width = 800; 
     
                var height = 460; 
     
                if (parseInt(navigator.appVersion) > 3) { 
                    if (navigator.appName == "Netscape") { 
                        height = window.innerHeight; 
                    } 
                    if (navigator.appName.indexOf("Microsoft") != -1) { 
                        height = document.body.offsetHeight; 
                    } 
                } 
     
                modalWindow.setSize(width + 50, height - 50); 
                modalWindow.show(); 
            } 

  10. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 24 Apr 2009 Link to this post

    Hello Greg,

    Do you by any chance close the RadWindow from the code-behind? If so, I suggest to return the AutoSize setting and execute the closing script with a little timeout, e.g 300 ms. If this is not the case, please prepare a sample reproduction demo, open a new support ticket and send it to us along with detailed explanations and reproduction steps.


    Regards,
    Svetlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  11. Greg
    Greg avatar
    17 posts
    Member since:
    Mar 2009

    Posted 24 Apr 2009 Link to this post

    I am closing it from javascript. I added a close event using add_close and it executes this script:

            function refreshLocationsGrid(sender, args) { 
                sender.remove_close(refreshLocationsGrid); 
                sender.hide(); 
                var button = $get('<%=Button_RefreshLocations.ClientID %>'); 
                button.click(); 
            } 

    This code also causes a button to be clicked which updates a gridview inside of an update panel. I have already tried removing the button click and I get the same results.
  12. Brian
    Brian avatar
    4 posts
    Member since:
    Mar 2009

    Posted 27 Apr 2009 Link to this post

    Greg:

    You got it! Its the AutoSize property!

    Thank you very much, its something I've been wrestling with for a while now. I actually downgraded to the Ajax Toolkit for their ModalPopupExtender to work around the issue; but now that I can close it properly, back to Telerik for me.

    Thanks everyone for your hard work.
  13. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 27 Apr 2009 Link to this post

    Hello guys,

    Greg, as far as I can see from your code, the sender is the RadWindow object and you want to close it by using the method hide(). Please, note that the hide method of RadWindow is not recommended to be used and in order to close correctly the RadWindow you should call close() instead as explained below:

    http://www.telerik.com/help/aspnet-ajax/window_programmingradwindowmethods.html

    In case you still experience the issue, please prepare a sample reproduction demo, open a new support ticket and send it to me along with detailed reproduction steps and I will modify it in order to meet your requirements.

    Brian, I am glad that you solved the problem, in case you experience any other problem, do not hesitate to contact us.


    Kind regards,
    Svetlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  14. sullivanst
    sullivanst avatar
    5 posts
    Member since:
    May 2007

    Posted 12 May 2009 Link to this post

    I'd just like to chip in with a "me too!" since I'm coming off the back of 3 hours of trying to wrestle with this exact problem.

    My problem window is autosized by the opener and closed by javascript output by a server-side button event handler. Taking the autosize off makes the problem go away.

    After a failed attempt to close the window, using FireBug to examine the window object showed that it had been marked as closed, but was still rendered anyway. This explains why clicking the 'X' in the top-right didn't close the window after the bug had been triggered.

    I tried making the postback from within the window a RadAjax callback instead, but that just caused a different javascript error in the autosize code - although at least in that case it didn't leave the RadWindow object thinking it had already been closed

    To me it seems like a bug in the autosize code - it's trying to autosize after the window's been closed, and it really shouldn't. It should check whether the window's closed, and if so do nothing.
  15. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 14 May 2009 Link to this post

    Hello guys,

    I am glad to inform you that we accepted and already included the fix, suggested by Mathew and it will be available in the next build. For the time being we suggest to use the timeout solution as a temporary workaround.

    Thanks again for your feedback and cooperation!


    All the best,
    Svetlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  16. Lawrence
    Lawrence avatar
    1 posts
    Member since:
    May 2009

    Posted 20 May 2009 Link to this post

    Could anyone please post an example for the temporary workaround? I tried to use window.setTimeout and set the delay to 300 but that doesn't solve my problem. The only way I can get the RadWindow close is to turn off AutoSize.

     

    Thanks,

    Lawrence

  17. sullivanst
    sullivanst avatar
    5 posts
    Member since:
    May 2007

    Posted 20 May 2009 Link to this post

    Sure... I'm using prototype so my code will probably need to be de-prototyped for it to be of use to you. Here's the version I know definitely works, using prototype:
    <html>    
    <body>    
    <script type='text/javascript'>     
    Event.observe(window, 'load', function() {     
        (function() { GetRadWindow().close(); }).defer();     
    });     
    </script>    
    </body> 
    </html> 

    De-prototyped, it should be functionally equivalent to the following:

    <html> 
    <head> 
    <script type='text/javascript'>  
    function closeOnLoad() {  
        window.setTimeout(function() { GetRadWindow.close(); }, 300);  
    }  
    </script> 
    </head> 
    <body onload='closeOnLoad();'>  
    </body> 
    </html> 
     
     
  18. Mario
    Mario avatar
    75 posts
    Member since:
    Jun 2009

    Posted 29 Apr 2010 Link to this post

    hi,

    [- deleted message -]

    solved itself ^^

    - Mario
  19. Baktha
    Baktha avatar
    2 posts
    Member since:
    Aug 2015

    Posted 18 Aug 2015 in reply to Svetlina Anati Link to this post

    Pop Up Rad window not close properly . If i using drop down in Rad window pop up, then i click the close icon but not close full popup window. anybody help me
  20. Stamo Gochev
    Admin
    Stamo Gochev avatar
    157 posts

    Posted 21 Aug 2015 Link to this post

    Hello Baktha,

    Can you provide us with a more detailed explanation of the problem, e.g.:
    • sample page with the configuration of RadWindow
    • a list of steps to reproduce the issue
    • the version of our product that you are testing with
    • browsers (and their version) in which the problem can be reproduced
    Your effort will be highly appreciated.

    Regards,
    Stamo Gochev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017