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

Close Window from itself

1 Answer 99 Views
Window
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 26 Apr 2012, 10:58 PM
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.
 

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Apr 2012, 05:41 AM
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.

Tags
Window
Asked by
Dave
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or