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

RadWindow OnClientClose not working

11 Answers 986 Views
Window
This is a migrated thread and some comments may be shown as answers.
Baris
Top achievements
Rank 2
Baris asked on 20 May 2011, 05:39 PM
I am using radwindowmanager on my master page and my other aspx pages are showing radwindows using this manager. except one aspx page, everything is working as expected. on this problematic page i have nothing different, I have the radwindow shown but the bloody OnClientClose event is not working! On other pages when i delete the OnClientClose function on javascript code, it gives me the event is not defined error as normal. but on the problematic page when i delete the OnClientClose, it doesnt even give an error. 

function confirm(text) {
             var oManager = GetRadWindowManager();
             var oWnd = oManager.open(null, "RadWindow6");
             oWnd.SetTitle(text);
         }

<telerik:RadWindow ID="RadWindow6" runat="server" Animation="None" Behavior="Default"
                Height="170px"
                InitialBehavior="None" Left="" Modal="True" NavigateUrl="~/popups/ConfirmWindow.aspx" OnClientClose="OnClientClose"
                Overlay="True" Top="" VisibleStatusbar="False" Width="360px" Skin="WebBlue" Behaviors="Move,Close" >
            </telerik:RadWindow>

and here's the script that is added to a close button on the ConfirmWindow.aspx page which is inside this radwindow (works and closes the window as expected) :

function CloseWindow(type) {
        var oWnd = GetRadWindow();
        var oArg = new Object();
        oArg.result = false;
        oArg.type = type;
        oWnd.close(oArg);
    }



the javascript func is opening radwindow and my close button is closing the window but OnClientClose is not working, not even seeked! What am I missing?

11 Answers, 1 is accepted

Sort by
0
Gimmik
Top achievements
Rank 1
answered on 20 May 2011, 07:10 PM
Do you have a javascript function called "OnClientClosed"? Does it get fired?

0
Baris
Top achievements
Rank 2
answered on 21 May 2011, 12:36 AM
yes I have : "but on the problematic page when i delete the OnClientClose function, it doesnt even give an error. " which means my radwindow doesnt seek an OnClientClose function when it is closed on that specific aspx page. it works and fires the function on other pages. I must be missing sth.. I am desperately examining the code line by line but it looks same as my other aspx pages.

btw Gimmik, the topic is only about my OnClientClose function not firing and you're asking me if its firing.interesting =)
0
Georgi Tunev
Telerik team
answered on 24 May 2011, 11:31 AM
Hi guys,

To be fair, a function that is not working and a function that is not fired at all are 2 different scenarios in many cases :)

Anyway, when you say that the function is not working, I assume that even if you add a standard alert in that function, it is not fired at all, is that so? If yes, you most probably have a second RadWindowManager on that page. In such case, you need to take into consideration the following:

   1. All RadWindowManager's functions (radopen, radalert, radconfirm, radprompt, GetRadWindowManager, etc) are always using the first rendered RadWindowManager on the page.
   2. Every RadWindowManager "knows" only the RadWindows that are declared in its Windows collection.

This means that if you have a RadWindow2 as a standalone control OR declared in RadWindowManager2, and you use something like radopen(myUrl, "RadWindow2");, radopen will use RadWindowManager1 and will open a new RadWindow with the settings taken from RadWindowManager1.
To avoid that problem, when you have multiple managers on a page, you need to get a reference to the correct RadWindowManager first and then call its methods.
e.g.
var manager = $find("<%= RadWindowManager2.ClientID %>");
manager.open(myUrl, "RadWindow2");   


I hope this information helps. If it doesn't, please open a support ticket and send me the code for the masterpage and the problematic content one, so I could check them.


Greetings,
Georgi Tunev
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Baris
Top achievements
Rank 2
answered on 25 May 2011, 03:28 PM
I found the problem and second radwindowmanager wasnt the cause as I dont have a second.
Here I draw a picture of my scenario (this new paint is funny =) ) http://img189.imageshack.us/img189/3250/unledqze.png

my aspx and ascx were both implementing OnClientClose functions but the problematic page was my aspx. I found out that the radwindow on my aspx was triggering the OnClientClose func on ascx as I am using the same RadWindow on both pages.

I feel stupid not to think of this before.. 
0
Salik
Top achievements
Rank 1
answered on 31 Jul 2015, 07:24 AM
Thank You (y) first point helped Me
0
Ninos
Top achievements
Rank 1
answered on 19 Jun 2017, 11:50 PM

Guys, I can't find a solution to my problem related to OnClientClose not triggering.

1. i don't have more than one RadWindowManager.

2. I don't have more than one listener to OnClientClose, like explained by Baris.

3. I have it as simple as the example here, http://docs.telerik.com/devtools/aspnet-ajax/controls/window/client-side-programming/events/onclientclose

 

Below is what I have, and when the call oWnd.close() is made the onEulaClose is not fired.

Any help will be appreciated.

 

EULA.aspx (Called page by Default):

<script type="text/javascript">

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

        function DoAccept() {
            var oWnd = GetRadWindow();
            oWnd.close();
        }

</script>

<asp:Button ID="btn_close" runat="server" Text="I Accept" OnClick="DoAccept_Click" />

 

The code behind DoAccept_Click, eventually calls back into Javascript's function DoAccept()

 

Default.aspx (Calling page):

 

<script type="text/javascript">

    function onEulaClose(sender, args) {
            alert('got here');
        }

        function displayEULAMessage() {
            var oWnd = radopen("/EULA.aspx", "eulaWin");
            setBehaviors(oWnd);
        },

     function setBehaviors(oWnd) {
            oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.None);
            oWnd.set_visibleStatusbar(false);
            oWnd.set_modal(true);
        }

</script>

<telerik:RadWindowManager ID="rwm1" runat="server">
        <Windows>

              <telerik:RadWindow ID="eulaWin"    RenderMode="Lightweight" runat="server" Behaviors="None"        KeepInScreenBounds="true" Skin="WebBlue" EnableEmbeddedSkins="false" IconUrl="" 
       Height="550px" Width="800px" Modal="true" BorderStyle="None" ShowContentDuringLoad="false" ReloadOnShow="false" VisibleStatusbar="false" Title="EULA" 
                OnClientClose="onEulaClose"/>

 

        </Windows>

</telerik:RadWindowManager>

0
Ranjith
Top achievements
Rank 1
answered on 20 Apr 2020, 08:09 PM

Hello, I am seeing this issue as well. I am passing the rad window manager and open with that manager, but the OnClientClose would execute only on the first call and the subsequent calls would fail to call it. Anything else I need to do?

 

var manager = $find("<%= RadWindowManager2.ClientID %>");
manager.open(myUrl, "RadWindow2");   

0
Doncho
Telerik team
answered on 21 Apr 2020, 01:16 PM

Hello Ranjith,

A potential cause of the event not firing on window close might be a JavaScript exception on the page. Please ensure you don't have any errors on the page. I suggest using the Browser's developer tools to inspect the page and monitor it for JavaScript exceptions. For more information/tips, please check out the "Debug JavaScript" section of the Improve Your Debugging Skills with Chrome DevTools Blog Post.

Here is a sample scenario that shows opening a RadWindow on button click. The OnClientClose event handler is attached to the RadWindow. Each client close will log a message on the console.

Markup

<telerik:RadWindowManager ID="RadWindowManager1" runat="server">
    <Windows>
        <telerik:RadWindow ID="RadWindow1" runat="server" OnClientClose="clientClose"></telerik:RadWindow>
    </Windows>
</telerik:RadWindowManager>
<telerik:RadButton ID="RadButton1" runat="server" Text="RadButton" OnClientClicked="clientClicked" AutoPostBack="false"></telerik:RadButton>

 

JavaScript

function clientClicked(sender, args) {
    var manager = $find("<%= RadWindowManager1.ClientID %>");
    var wind = manager.open(null, "RadWindow1");  
}
function clientClose(sender, args) {
    console.log("window closed");
}

You may also find the following articles helpful:

 

I hope that will help.

Kind regards,
Doncho
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Ranjith
Top achievements
Rank 1
answered on 21 Apr 2020, 01:58 PM

Hi Doncho,

 

Thanks for the quick reply. Yes, there are no Javascript errors of any kind. It "does" execute the close script once or twice, but on the "subsequent" calls, it doesn't call!

0
Doncho
Telerik team
answered on 22 Apr 2020, 05:26 PM

Hello Ranjith,

At this point, we are stepping in the dark. To be able to help, we would require more information about the current configuration and/or describe the steps that will help us replicate the problem locally.

Once we can see the problem, we will debug the issue and share the details.

Kind regards,
Doncho
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
James
Top achievements
Rank 1
answered on 11 May 2020, 09:58 PM

Ranjith, you may be able to manually assign the close function when you open the window.

something like 
                wind.add_close(clientclose);

placed just after your manager.open line worked for me when I had a similar issue.

Tags
Window
Asked by
Baris
Top achievements
Rank 2
Answers by
Gimmik
Top achievements
Rank 1
Baris
Top achievements
Rank 2
Georgi Tunev
Telerik team
Salik
Top achievements
Rank 1
Ninos
Top achievements
Rank 1
Ranjith
Top achievements
Rank 1
Doncho
Telerik team
James
Top achievements
Rank 1
Share this question
or