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

RadWindow from server

2 Answers 68 Views
Window
This is a migrated thread and some comments may be shown as answers.
Naupad
Top achievements
Rank 1
Naupad asked on 16 Feb 2012, 11:32 PM
I have this function on my aspx page.
function openWindow() {
          
            //get a reference to the window
            var oWnd = $find("<%= RadWindow2.ClientID %>");
            //set its NavigateUrl
            oWnd.setUrl("http://xyz.com/abc.zip");
            //add the name of the function to be executed when RadWindow is closed
            
            //show the window
            oWnd.show();
        }

I want to call this function in Button click event through RegisterStartupScript. It gets called but window doesn't open. Also I want to open a url which has a zip file for download. So as soon as user is prompted about Save dialog box, I want to close radwindow.

HELP!!!!!

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 17 Feb 2012, 05:42 AM
Hello,

Try the following code to open RadWindow through RegisterStartupScript.
C#:
protected void Button1_Click(object sender, EventArgs e)
  {
    string openWindowScript = "<script language='javascript'>function f(){openWindow(); Sys.Application.remove_load(f) ;}; Sys.Application.add_load(f)  ;</script>";
    Page.ClientScript.RegisterStartupScript(this.GetType(), "radalert", openWindowScript);
  }

Thanks,
Princy.
0
Svetlina Anati
Telerik team
answered on 17 Feb 2012, 09:59 AM
Hi guys,

 I suggest to improve the sample code Princy provided in the following manner:

1) Use ScriptManager instead of ClientScript - this will handle more scenarios, e.g when an AJAX request was made.

2) Since your js function already has a name, it is not needed to wrap it the additional named f function.

With the above your code will look like the following:

js in aspx:

function openWindow() {
           Sys.Application.remove_load(openWindow);
             //get a reference to the window
             var oWnd = $find("<%= RadWindow2.ClientID %>");
             //set its NavigateUrl
             oWnd.setUrl("http://xyz.com/abc.zip");
             //add the name of the function to be executed when RadWindow is closed
              
             //show the window
             oWnd.show();
         }

code-behind:

protected void Button1_Click(object sender, EventArgs e)
  
  {
  
 
 ScriptManager.RegisterStartupScript(this, this.GetType(), "key", "Sys.Application.add_load(openWindow)" , true);
  
  }


You can find a more detailed article about opening RadWindow from the server below:

http://www.telerik.com/help/aspnet-ajax/radwindow-troubleshooting-opening-from-server.html

I hope that my reply is helpful, let me know how it goes.

Kind regards,
Svetlina Anati
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
Window
Asked by
Naupad
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Svetlina Anati
Telerik team
Share this question
or