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

Client-side Dialog Close

9 Answers 286 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Matt Thrower
Top achievements
Rank 1
Matt Thrower asked on 15 Oct 2008, 01:47 PM
Hi,

In the old version of RadEditor I was able to close open dialogs in Javascript with the command CloseDlg(). However, that code is no longer working and I can't find an equivalent in the documentation of the Ajax version. Can you point me in the right direction?

Cheers,
Matt

9 Answers, 1 is accepted

Sort by
0
Mike Austin
Top achievements
Rank 1
answered on 15 Oct 2008, 02:39 PM
I believe
Telerik.Web.UI.Dialogs.CommonDialogScript.get_windowReference().close(args); 
will work for you.
0
Mike Austin
Top achievements
Rank 1
answered on 15 Oct 2008, 02:39 PM
Dupe
0
Rumen
Telerik team
answered on 15 Oct 2008, 02:46 PM
Hi guys,

You can use

getRadWindow().close(closeArgument); //use the close function of the getRadWindow to close the dialog and pass the arguments from the dialog to the callback function on the main page.

This information is available in the following help article: Add Custom Dialogs.

Best regards,
Rumen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Matt Thrower
Top achievements
Rank 1
answered on 15 Oct 2008, 03:10 PM
Hi,

Thanks for the suggestions. Unfortunately, using getRadWindow().close(args) yields an 'object expected' Javascript error and using Telerik.Web.UI ...getRadWindow yields a 'Telerik is undefined' Javascript error.

Cheers,
Matt
0
Rumen
Telerik team
answered on 15 Oct 2008, 03:28 PM
Hi Matt,

You should register the following javascript code needed for the RadWindow dialog initialization in the dialog file:

<script type="text/javascript">
function getRadWindow() //mandatory for the RadWindow dialogs functionality
{
   if (window.radWindow)
{
 return window.radWindow;
}
if (window.frameElement
&& window.frameElement.radWindow)
{
 return window.frameElement.radWindow;
}
return null;
}

function initDialog() //called when the dialog is initialized
{
   var clientParameters = getRadWindow().ClientParameters; //return the arguments supplied from the parent page
}
if (window.attachEvent)
{
   window.attachEvent("onload", initDialog);
}
else if (window.addEventListener)
{
   window.addEventListener("load", initDialog, false);
}

...

After that you will be able to use:

getRadWindow().close(closeArgument);


You can see how the following live examples works for example: Make Images From Text (the code of the dialog is available in the RadEditor demo installation folder) or download the following project: http://www.telerik.com/ClientsFiles/089510_showExternalDialog.zip.

Best regards,
Rumen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Matt Thrower
Top achievements
Rank 1
answered on 16 Oct 2008, 09:11 AM
Hi,

Inserting that script works for the places where I'm closing the dialog with null return value. However, in once instance I'm closing the dialog with a return value of some text, including HTML markup. This causes the following alert boxes to pop up in sequence:
Error while executing filter StripScriptsFilter - [object Error]
Error while executing filter EncodeScriptsFilter - [object Error]
Error while executing filter IEKeepObjectParamsFilter - [object Error]
Error while executing filter IEKeepCommentsFilter - [object Error]

Followed by a breaking Javascript error in the following function:
_encodeHtmlContent:function(_58,_59)

Any ideas as to what might be behind this?

Cheers,
Matt







0
Rumen
Telerik team
answered on 20 Oct 2008, 02:53 PM
Hi Matt,

Could you please, send us a sample working example and content which demonstrate the problem? Once we reproduce the problem, we will be able to see whether the problem is due to a non-well-formed HTML content or not.

Best regards,
Rumen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
sarika
Top achievements
Rank 1
answered on 11 Mar 2009, 06:42 PM

Hi,
I am also getting the same errors when closing the RadWindow.

 

I have this on the popup page.

 

<%

@ Page Language="C#" AutoEventWireup="true" CodeFile="SendEmail.aspx.cs" Inherits="Popup" %>  

 

 

<%

@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>  

 

 

<!

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  

 

 

<

html xmlns="http://www.w3.org/1999/xhtml">  

 

 

<

head runat="server">  

 

 

 

<title></title>  

</

head>  

 

 

<

body onload="addContent();">   

 

 

 

<script language="javascript" type="text/javascript">

 

 

 

 

 

function GetRadWindow()

 

{

 

 

var oWindow = null;

 

 

if (window.radWindow)

 

oWindow = window.radWindow;

 

 

else if (window.frameElement.radWindow)

 

oWindow = window.frameElement.radWindow;

 

 

return oWindow;

 

}

 

 

function CloseRadWindow()

 

{

 

 

var oWindow = GetRadWindow();

 

oWindow.argument =

 

null;

 

oWindow.close();

}

 

 

function addContent()

 

{

Sys.Application.add_load(LoadContent);

}

 

 

 

function LoadContent()

 

{

 

 

var currentWindow = GetRadWindow(); 

 

 

var editor = $find("<%= rdContent.ClientID %>");

 

editor.set_html(currentWindow.argument);

Sys.Application.remove_load(LoadContent);

}

 

 

</script 

 

 

<form id="formSendEmail" runat="server">

 

 

 

 

 

<asp:ScriptManager ID="CommunicationsPortalSendEmailScriptManager" runat="server">

 

</asp:ScriptManager 

 

 

<div 

 

 

<telerik:RadEditor ID="rdContent" runat="server" Height="125px" Width="270px" Skin="Gray"

 

 

 

 

EditModes="Design" ToolsFile="~/App_Data/SendEmail.xml"> </telerik:RadEditor 

 

 

<asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="btnCancel_Click" />  

 

</div>   

 

 

</form>

 </

body>
</
html>

On code behind I have 

 

 

protected

void btnCancel_Click(object sender, EventArgs e)  

 

 

//Close this window  

 

 

this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CloseWindow", "CloseRadWindow();", true);  

}

And at the time of closing this popup, I do not need to pass any parameters to the parent page which opened this popup window. I just need to close it.

Can you please help me in this matter?

Thank you.
Sarika

 

 

0
Fiko
Telerik team
answered on 12 Mar 2009, 03:01 PM
Hello Sarika,

I have just answered your question in your support ticket on the same subject. In general, the idea is to use ScriptManager's RegisterStartupScript() method.

Sincerely yours,
Fiko
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Editor
Asked by
Matt Thrower
Top achievements
Rank 1
Answers by
Mike Austin
Top achievements
Rank 1
Rumen
Telerik team
Matt Thrower
Top achievements
Rank 1
sarika
Top achievements
Rank 1
Fiko
Telerik team
Share this question
or