Client Side – Rad Window Close Event

on Thursday, May 23, 2013
when a RadWindow is closed, its object is not destroyed but remains hidden on the page so it can be quickly called again when needed. There are 2 ways to avoid that issue: Set DestroyOnClose=true. Use the OnClientClose event handler that is called every time when a RadWindow is closed. There you could use setUrl() client-side method to change the content page’s Url which will stop the media as well. e.g.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RadWindow.aspx.cs" Inherits="DUMMY_RadWindow" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function ShowWindow() {
            var oWnd = window.radopen('Dialog1.aspx', 'window1'); //Opens the window  
            oWnd.add_close(OnClientClose); //set a function to be called when RadWindow is closed  
        }
        function OnClientClose(oWnd) {
            oWnd.setUrl("about:blank"); // Sets url to blank 
            oWnd.remove_close(OnClientClose); //remove the close handler - it will be set again on the next opening 
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="SC1" runat="server"></asp:ScriptManager>
    <div>
<telerik:RadWindowManager ID="RadWindowManager1" runat="server"> 
</telerik:RadWindowManager> 
<button onclick="ShowWindow(); return false;"> 
    open RadWindow</button>
    </div>
    </form>
</body>
</html>

0 comments:

Post a Comment