Skip to content Skip to sidebar Skip to footer

Dynamically Open A Radwindow Defined In Javascript

Objective:- From the server-side, I need to open a radwindow(defined in JavaScript of the aspx page) automatically on an IF condition. Code used:- In aspx page, I defined the radwi

Solution 1:

Hi I want to share with you my solution to create RadWindow dialog in Javascript code only.

We need to implement 2 methods: one for initializing RadWindow dialog, and the last one for recieving the arguments returned after closing the RadWindow. You can do what you want in this second step (e.x postback,...)

Here is my code:

Initializing RadWindow dialog:

functionopenMyDialog(url, args) {
    var manageWindow = GetRadWindowManager();
    if (manageWindow) {
        var radWindow = manageWindow.open(url, "<your_dialog_name>");
        if (radWindow) {
            radWindow.set_initialBehaviors(Telerik.Web.UI.WindowBehaviors.None);
            radWindow.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Resize);
            radWindow.setActive(true);
            radWindow.SetModal(true);
            radWindow.center();
            radWindow.set_visibleStatusbar(false);
            radWindow.set_keepInScreenBounds(true);
            radWindow.set_minWidth(640);
            radWindow.set_minHeight(480);
            radWindow.setSize(640, 480);
            radWindow.set_destroyOnClose(true);
            radWindow.add_close(closeMyDialog);//after closing the RadWindow, closeMyDialog will be called
            radWindow.argument = args;//you can pass the value from parent page to RadWindow dialog as this line
        }
    }
}

Closing the RadWindow dialog:

functioncloseMoveProjectDialog(sender, args) {
    var objArgs = args.get_argument();
    //objArgs variable stored the values returned from the RadWindow//you can use it for your purpose
}

How to call this? You can put the open method into your expected method. In my side, I have a method as shown below and I will call the RadWindow as this way:

functionShowForeignKeyFrontEditSingle(param1, param2){
    var url = "ForeignKeyFrontEditSingle.aspx";
    var objArgs = newArray();
    objArgs[0] = param1;
    objArgs[1] = param2;

    openMyDialog(url, objArgs);
    return;
}

Of course, you have to declare a RadWindowManager control

functionGetRadWindowManager() {
    return $find("<%=your_radwindow_manager_control.ClientID%>");
}

Solution 2:

Take a look here, it explains how to use the ScriptManager.RegisterStartupScript method: http://www.telerik.com/help/aspnet-ajax/window-troubleshooting-javascript-from-server-side.html. Note it the ScriptManager's method. Also look at the Sys.Application.Load event to prevent your code from executing too early.

Post a Comment for "Dynamically Open A Radwindow Defined In Javascript"