window.radWindow undefined?

6 posts, 0 answers
  1. Stephane
    Stephane avatar
    2 posts
    Member since:
    Oct 2012

    Posted 12 Dec 2012 Link to this post

    Hi everyone,

    I need your help.
    I added Telerik to a old project. radGrid works good, and i can open radWindow.
    I have followed this demo

    But for now, i can't close the radWindow, the reason : window.radWindow and window.frameElement.radWindow from GetRadWindow() script function are undefined.

    If someone can help me.

    My code :
    <telerik:RadScriptManager runat="server" EnableViewState="false" ID="RadScriptManager1" />
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
                function ShowEditForm(id, rowIndex) {
                    var anneeID = 0;
                    var typeRessID = 0;
                    var grid = $find("<%= RadGrid1.ClientID %>");
                    var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element();
                    anneeID = document.getElementById("<%= cboAnnees.ClientID %>").value;
                    if (document.getElementById("rbResident").checked == true) {
                        typeRessID = 1;
                    if (document.getElementById("rbExterne").checked == true) {
                        typeRessID = 2;
                    if (document.getElementById("rbAutre").checked == true) {
                        typeRessID = 3;
                    grid.get_masterTableView().selectItem(rowControl, true);
                    window.radopen("UpdateInfo.aspx?ID=" + id + "&TYPERESSID=" + typeRessID + "&ANNEEID=" + anneeID, "UserListDialog");
                    return false;
                function ShowInsertForm() {
                    window.radopen("UpdateRessourceFrameset.aspx", "UserListDialog");
                    return false;
                function refreshGrid(arg) {
                    if (!arg) {
                        $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
                    else {
                        $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate");
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
                <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl>

    <telerik:RadGrid OnItemCreated="RadGrid1_ItemCreated" ID="RadGrid1" runat="server"
            AllowPaging="True" EnableViewState="true" Width="97%">
            <PagerStyle Mode="NumericPages"></PagerStyle>
            <MasterTableView pagesEnableViewState="true" AutoGenerateColumns="False" DataKeyNames="RESS_ID" ShowHeadersWhenNoRecords="false" ClientDataKeyNames="RESS_ID"
                Width="100%" PageSize="20">
                    <telerik:GridBoundColumn DataField="INFO2" HeaderText="Year" ReadOnly="True">
                    <telerik:GridBoundColumn DataField="INFO1" HeaderText="Name"/>
                    <telerik:GridTemplateColumn UniqueName="TemplateEditColumn">
                            <asp:HyperLink ID="EditLink" runat="server" Text="Edit"></asp:HyperLink>
                    <a href="#" onclick="return ShowInsertForm();">No records...</a>
                <Selecting AllowRowSelect="false"></Selecting>
                <telerik:RadWindowManager ID="RadWindowManager1" EnableViewState="False" runat="server">
                <telerik:RadWindow ID="UserListDialog" runat="server" Title="Editer une ressource" Height="500px"
                    Width="930px" Left="150px" ReloadOnShow="true" ShowContentDuringLoad="false"

    Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As UI.AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest
           If e.Argument = "Rebind" Then
           ElseIf e.Argument = "RebindAndNavigate" Then
               RadGrid1.MasterTableView.CurrentPageIndex = RadGrid1.MasterTableView.PageCount - 1
           End If
       End Sub
       Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs)
           If TypeOf e.Item Is GridDataItem Then
               Dim editLink As HyperLink = DirectCast(e.Item.FindControl("EditLink"), HyperLink)
               editLink.Attributes("href") = "#"
               editLink.Attributes("onclick") = [String].Format("return ShowEditForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("RESS_ID"), e.Item.ItemIndex)
           End If
       End Sub

    <script type="text/javascript">
         function CloseAndRebind(args) {
         function GetRadWindow() {
            var oWindow = null;
             if (window.radWindow) oWindow = window.radWindow;
             else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
             return oWindow;
         function CancelEdit() {
    <asp:ScriptManager id="smUpdateRess" runat="server" />
    <asp:DetailsView runat="server" ID="DetailsView1" OnItemUpdating="DetailsView1_ItemUpdating" AutoGenerateEditButton="false" AutoGenerateRows="false" GridLines="None">
                       <asp:Button ID="btAddContact" runat="server" Text="Save Contact" CommandName="Update" />
                       <table border =0 style="width:750px">
                                <td  style="height: 31px" colspan=4>
                               <asp:Label id="lblInfo1" runat="server" Text="Year: "></asp:Label>                            
                               <asp:TextBox id="txtInfo2" runat="server" Width="70px"  ReadOnly="true"  BackColor="LightGray" Text='<%# Container.DataItem("Info2") %>'></asp:TextBox>     
                                 <asp:Label id="lblinfo2" runat="server" Text="Name:"></asp:Label>
                                <asp:TextBox ID="txtInfo1" runat="server" Width="70px"  ReadOnly="true"  BackColor="LightGray" Text='<%# Container.DataItem("INFO1") %>'></asp:TextBox>                    


    on button click
    ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CancelEdit();", True)

    But like i said, i get error of null with window.radWindow orwindow.frameElement.radWindow

    thanks for your help.
  2. Marin Bratanov
    Marin Bratanov avatar
    3555 posts

    Posted 13 Dec 2012 Link to this post

    Hi Stephane,

    This report is rather strange, yet I can suggest several ideas you can try:

    1) add a small timeout before closing the RadWindow, for example:
    you can try increasing the time if 0ms is not enough

    2) if you still have null from GetRadWindow() try calling window.close(). We override the default browser close() to close the RadWindow, because it has been requested by our clients in the past. Not that such an override is not possible in IE9 and this will not work there.

    3) call a function on the main page that will get a reference to the RadWIndow and close it, e.g.:

    Kind regards,
    Marin Bratanov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. DevCraft R3 2016 release webinar banner
  4. Hugh
    Hugh avatar
    10 posts
    Member since:
    Nov 2014

    Posted 15 Nov 2014 in reply to Marin Bratanov Link to this post

    I am having a similar problem.  I believe this was working initially, but no more.  the window.radWindow and window.frameElement are null on the child page.

    appreciate any assistance.
  5. Marin Bratanov
    Marin Bratanov avatar
    3555 posts

    Posted 17 Nov 2014 Link to this post

    Hi Steve,

    We have not been able to reproduce such a problem so I cannot offer a solution to the case. What I can suggest is looking into the following:

    • My third suggestion on calling a function on the main page that will close the RadWindow (you can read more details about this approach here:
    • See if both pages have the same domain set. If they don't, RadWindow's code cannot access the iframe in order to create the backreference, so you would need to call a function from the main page in order to close the dialog, or you would need to change the document.domain property so the pages are accessible to one another (as having different domains is likely to prevent you from calling the other function as well).
    • See if there are any prior script errors in the browser and if resolving them will also resolve the current issue as well.

    I hope this helps.


    Marin Bratanov

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  6. Ben
    Ben avatar
    3 posts
    Member since:
    Jul 2015

    Posted 14 Apr Link to this post

    I don't know if this will be helpful to anyone else but I was having a problem with a radWindow being undefined as well.The problem only occurs with a popup that's opened from the server through an ajax call. I was able to get around it by using GetRadWindowManager().getActiveWindow(). So now my GetRadWindow function looks like this

    function GetRadWindow() {
        var oWindow = null;
        if (window.radWindow){
            oWindow = window.radWindow;
        } else if (window.frameElement && window.frameElement.radWindow) {
            oWindow = window.frameElement.radWindow;
        } else {
            //if the window is opened from the server, window.radWindow doesn't seem to get created
            oWindow = GetRadWindowManager().getActiveWindow();
        return oWindow;

  7. Marin Bratanov
    Marin Bratanov avatar
    3555 posts

    Posted 18 Apr Link to this post

    Hello Ben,

    That can certainly be useful in certain scenarios.

    I would also advise you look into using the Sys.Application.Load event for executing such scripts because this is the earliest event in which the controls objects are sure to be created. You can read more on the subject in the following article:


    Marin Bratanov
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
DevCraft R3 2016 release webinar banner