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

Opening a RadWindow from Within a RadWindow

1 Answer 98 Views
Window
This is a migrated thread and some comments may be shown as answers.
EpiqDev
Top achievements
Rank 2
EpiqDev asked on 19 Jan 2011, 09:51 PM
I am trying to open a radwindow from an already opened window. I need both of them at the same hierarchy level as well as being modal windows.
After reading http://www.telerik.com/help/aspnet-ajax/window_programmingopeningfromwithin.html I was able to open the second window using RadWindow and a javascript function. Unfortunately, the second window showed up behind the current one which was not the desired behavior. I tried several methods such as setActive() and show() methods but neither proved to be working for me. So I decided to hide the current window and open the second window while adding a callback method using add_close() event handler to unhide the hidden original window after the second window gets closed. This method is producing an "out of stack space" error. Now I have to mention that I add a callback on every radwindow close event without any problem and this was done exactly the same way so I doubt that I was incorrectly using the add_close() method. And if I take out oWnd.add_close(callback); from the javascript code, it works fine except that I cannot bring the original window back. Is there a way I can get this to work?
Here are the relevant mark up and javascript codes:

RadWindow Markup in parent.ascx, child_original.aspx, child_second.aspx files:
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="Black">
</telerik:RadWindowManager>

javascript code in parent.ascx file which opens the original pop-up form:
function ID_OnClientClicked(ID) {
    var url = "/Portal/child_original.aspx";
    var strTabID = "?TabID=" + $get(OpenTab).value;
    var qryString = "&ID=" + ID;
    OpenTelerikWindow(url, strTabID, qryString, 800, 400, "Info 1", Child_Original_OnClientClose, "Info1");
}
  
function Child_Original_OnClientClose(oWnd, args) {
    var arg = args.get_argument();
    if (arg && arg.Rebind) {
        $find(AjaxPanel).ajaxRequest(arg.ID);
    }
    oWnd.SetUrl('about:blank');
    oWnd.remove_close(Child_Original_OnClientClose);
    oWnd.Close();
}

javascript code in original pop-up form (child_original.aspx) which opens the second pop-up form:
function Child_Original_OnClientClicked(ID) {
    var url = "/Portal/Child_second.aspx";
    var strTabID = "?TabID=" + $get(OpenTab).value;
    var qryString = "&ID=" + ID;
    OpenParentTelerikWindow(url, strTabID, qryString, 1000, 700, "Info2", Info2_OnClientClose, "Info2");
}

common javascript code being shared by all of them:
function OpenTelerikWindow(formURL, strTabID, strQueryString, width, height, title, callback, name) {
    var windowID = ResolveUrl(formURL) + strTabID + strQueryString;
    if (windowID != "") {
        var oWnd = radopen(windowID, name);
        oWnd.setSize(width, height);
        oWnd.set_modal(true);
        oWnd.set_title(title);
        oWnd.set_visibleStatusbar(false);
        oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Close);
        if (callback != null && callback != undefined) oWnd.add_close(callback);
    }
}
  
function OpenParentTelerikWindow(formURL, strTabID, strQueryString, width, height, title, callback, name) {
    var windowID = ResolveUrl(formURL) + strTabID + strQueryString;
    if (windowID != "") {
        var curWnd = GetRadWindow();
        var oBrowserWnd = curWnd.BrowserWindow;
        var oWnd = oBrowserWnd.radopen(windowID, name);
        oWnd.setSize(width, height);
        oWnd.set_modal(true);
        oWnd.set_title(title);
        oWnd.set_visibleStatusbar(false);
        oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Close);
        if (callback != null && callback != undefined) oWnd.add_close(callback);
        //oWnd.show();
        oWnd.setActive();
        curWnd.hide();
    }
}
  
function GetRadWindow() {
    var oWindow = null;
    if (window.radWindow) oWindow = window.radWindow;
    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
    return oWindow;
}
  
function Info2_OnClientClose(oWnd, args) {
 // method to bring back the original child form back: to be implemented
    oWnd.SetUrl('about:blank');
    oWnd.remove_close(Info2_OnClientClose);
    oWnd.Close();
}

Call stack when "out of stack space" error occurs:
Function$_validateParams    JScript 
Error$argumentType  JScript 
Function$_validateParameterType JScript 
Function$_validateParameter JScript 
Function$_validateParams    JScript 
Error$argumentType  JScript 
Function$_validateParameterType JScript 
Function$_validateParameter JScript      
<<Repeats over 100 times... Clipped>>      
Function$_validateParams    JScript 
Error$argumentType  JScript 
Function$_validateParameterType JScript 
Function$_validateParameter JScript 
Function$_validateParams    JScript 
Sys$EventHandlerList$addHandler JScript 
JScript anonymous function  JScript 
OpenParentTelerikWindow JScript 
    
Error occurring at: 
OpenParentTelerikWindow: oWnd.add_close(callback); 
JScript anonymous function: c.extend({registerControlEvents:function(e,d){c.each(d,function(f,g){e.prototype["add_"+g]=function(h){this.get_events().addHandler(g,h)
};
Sys$EventHandlerList$addHandler:         var e = Function._validateParams(arguments, [
            {name: "id", type: String},
            {name: "handler", type: Function}
        ]);
Function$_validateParams: e = Function._validateParameter(params[i], expectedParam, paramName);
Function$_validateParameter: e = Function._validateParameterType(param, expectedType, expectedInteger, expectedDomElement, mayBeNull, paramName);
Function$_validateParameterType: e = Error.argumentType(paramName, Object.getType(param), expectedType);
Error$argumentType: var e = Function._validateParams(arguments, [
        {name: "paramName", type: String, mayBeNull: true, optional: true},
        {name: "actualType", type: Type, mayBeNull: true, optional: true},
        {name: "expectedType", type: Type, mayBeNull: true, optional: true},
        {name: "message", type: String, mayBeNull: true, optional: true}
    ]);

1 Answer, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 24 Jan 2011, 03:34 PM
Hello EncoreDev,

I believe that this thread will be of help:
http://www.telerik.com/community/forums/aspnet-ajax/window/using-add-resize-to-subscribe-to-client-side-window-resize-events.aspx#950974


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.
Tags
Window
Asked by
EpiqDev
Top achievements
Rank 2
Answers by
Georgi Tunev
Telerik team
Share this question
or