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

Close RadWindow From Server?

6 Answers 625 Views
Window
This is a migrated thread and some comments may be shown as answers.
David Nowak
Top achievements
Rank 1
David Nowak asked on 30 Jan 2008, 04:49 PM
I have some code that executes in the code-behind of the RadWindow.  I would like to close the window just as soon as that particular server code is finished.  Is there a way to do this?

Thank You,

David Nowak.

6 Answers, 1 is accepted

Sort by
0
David Nowak
Top achievements
Rank 1
answered on 30 Jan 2008, 05:47 PM
I found it!

Create a label on the form having no text so that it is invisible.  In the code-behind set the text property of the label to the following string to execute a function that will cause the form to close:

InjectScript.Text =

"<script>CloseFormFromServer()</" + "script>";

Ensure that a function exists having the same name as that injected into the label, and Voila we have server-side code executing with a javascript function occurring on demand!


0
Sean Marchiafava
Top achievements
Rank 1
answered on 06 Feb 2008, 07:25 PM
I'm trying to open a window in the same fashion but if the control that triggers the sever side event which injects the script is ajaxified then the client side script never gets executed. If I remove ajax from the triggering control it works. I tried updating the label control from the ajaxified trigger control and it still didn't work. Can anyone confirm that this method works with an ajaxified control as the trigger and without posting the entire page back? I'm interested in a radgrid itemcommand event that injects script to open a window. 
0
Georgi Tunev
Telerik team
answered on 07 Feb 2008, 12:58 PM
Hello Sean,

I don't know how exactly you ajaxify your code, but I would suggest to make sure that the script in the function is executed - for example you can replace the code with a simple alert.

Please note that this issue is not directly related to the RadWindow control, but it is a general task - e.g. to execute a Javascript function called from the server. Depending on your setup, there are different approaches. For example you can check the following KB article that shows how to call radalert() from the server - I believe the code samples there will be of help:
http://www.telerik.com/support/kb/article/b454K-gtd-b454T-cec-b454c-cec.aspx




Regards,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Sherry
Top achievements
Rank 1
answered on 31 Mar 2009, 06:16 PM

I'm doing this within a radAjaxPanel and it won't close...

 

 

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();

}


I use the following label: <asp:Literal ID="litCloseWindow" runat="server" />

 

 

Here is the text I give it: litCloseWindow.Text = "<script language='javascript'>alert('test');CloseWindow();</" + "script>"

I see that the Javascript is outputting but the client never executes it.... 

 

0
Shinu
Top achievements
Rank 2
answered on 01 Apr 2009, 07:59 AM
Hello Edward,

I tried the scenario and its working fine on my end. Can you try alternate option for calling client side function from code behind and see whether its working as expected.

CS:
protected void Button3_Click(object sender, EventArgs e) 
    Page.ClientScript.RegisterStartupScript(GetType(), "key""<script type='text/javascript'>CloseWindow();</script>"false); 

If you are using the classic ASP.NET version of RadControls, then please make sure that you set the EnableOutsideScripts property of RadAjaxPanel to True, and try the code snippet given above for clossing the window.

Thanks,
Shinu.
0
DEBAL
Top achievements
Rank 1
answered on 24 Aug 2012, 12:20 PM
Oh, Shinu
you are great , I was in trouble with this problem but you save my day .
Thanks
Debal
Tags
Window
Asked by
David Nowak
Top achievements
Rank 1
Answers by
David Nowak
Top achievements
Rank 1
Sean Marchiafava
Top achievements
Rank 1
Georgi Tunev
Telerik team
Sherry
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
DEBAL
Top achievements
Rank 1
Share this question
or