This is a migrated thread and some comments may be shown as answers.

My RadWindow won't close!

18 Answers 829 Views
Window
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 03 Apr 2009, 05:25 PM
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!

18 Answers, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 06 Apr 2009, 03:08 PM
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.
0
Brian
Top achievements
Rank 1
answered on 07 Apr 2009, 05:59 PM
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.
0
Svetlina Anati
Telerik team
answered on 09 Apr 2009, 12:39 PM
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.
0
Randy Skabelund
Top achievements
Rank 1
answered on 10 Apr 2009, 02:40 AM

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

0
Brian
Top achievements
Rank 1
answered on 20 Apr 2009, 07:13 PM
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.
0
Svetlina Anati
Telerik team
answered on 21 Apr 2009, 08:18 AM
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.
0
Accepted
Greg
Top achievements
Rank 1
answered on 24 Apr 2009, 02:56 PM
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(); 
        } 

0
Svetlina Anati
Telerik team
answered on 24 Apr 2009, 03:03 PM
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.
0
Greg
Top achievements
Rank 1
answered on 24 Apr 2009, 03:07 PM
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.
0
Brian
Top achievements
Rank 1
answered on 27 Apr 2009, 12:22 PM
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.
0
Svetlina Anati
Telerik team
answered on 27 Apr 2009, 12:36 PM
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.
0
Matthew
Top achievements
Rank 1
answered on 12 May 2009, 06:51 PM
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.
0
Svetlina Anati
Telerik team
answered on 14 May 2009, 12:49 PM
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.
0
Lawrence
Top achievements
Rank 1
answered on 20 May 2009, 02:11 PM

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

0
Matthew
Top achievements
Rank 1
answered on 20 May 2009, 02:21 PM
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> 
 
 
0
Mario
Top achievements
Rank 2
answered on 29 Apr 2010, 02:14 PM
hi,

[- deleted message -]

solved itself ^^

- Mario
0
Baktha
Top achievements
Rank 1
answered on 18 Aug 2015, 11:35 AM
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
0
Stamo Gochev
Telerik team
answered on 21 Aug 2015, 08:20 AM
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
Tags
Window
Asked by
Brian
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Brian
Top achievements
Rank 1
Randy Skabelund
Top achievements
Rank 1
Greg
Top achievements
Rank 1
Matthew
Top achievements
Rank 1
Lawrence
Top achievements
Rank 1
Mario
Top achievements
Rank 2
Baktha
Top achievements
Rank 1
Stamo Gochev
Telerik team
Share this question
or