Close Window from itself

2 posts, 0 answers
  1. Dave
    Dave avatar
    17 posts
    Member since:
    Jul 2005

    Posted 26 Apr 2012 Link to this post

    I have a page that opens a radWindow (called "radUserManager") and load the UserManager.aspx page:

    <telerik:RadWindow ID="radUserManager" runat="server" 
        NavigateUrl="UserManager.aspx" Height="500" Width="950" Modal=true 
        Style="z-index: 7001" Behaviors="Close, Reload" Top="-500px"></telerik:RadWindow>

    On UserManager.aspx, I have a radButton like this:
    <telerik:RadButton ID="cmdCancel" runat="server" Skin="Windows7" Text="Cancel" Width="75px" OnClientClick="CloseWindow(); return false;" >
    </telerik:RadButton>

    The CloseWindow code looks like this:
    function GetCommentRadWindow() {
      var oWnd = GetRadWindowManager().getWindowByName("radUserManager");
        return oWnd;
    }
    function CloseWindow() {
        GetCommentRadWindow().close();
    }

    Problem is, the window does not close. Nothing seems to happen.
     
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Apr 2012 Link to this post

    Hi Dave,

    Here is the sample code I tried to achieve your scenario.

    ASPX:
    <telerik:RadButton ID="cmdCancel" runat="server" Skin="Windows7" Text="Cancel" Width="75px" OnClientClicked="CloseWindow" ButtonType="StandardButton">
    </telerik:RadButton>

    JS:
    <script type="text/javascript">
      function GetRadWindow()
        {
            var oWindow = null;
            if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
            else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well)
            return oWindow;
        }
      function CloseWindow()
        {
            GetRadWindow().close();
        }
    </script>

    Regards,
    Shinu.

Back to Top