How to close the Window within ASP.Net

Hector

Is there a way to close the Rad Window from Asp.Net code? I have an RadHTMLPlaceHolder inside of a window and where I load a webpage to export a report. Once it is done exporting, I need it to automatically close the Rad Window. I tried adding closing it through JavaScript, but it closes the window to the Silverlight app. I found an article on accessing managed code through Asp.Net and from JavaScript, and this seems it would work, however, because the page that I am loading inside the RadWindow does not have the Silverlight control on it, I cannot call the code. Is there any way to do this?

Kaloyan

You are correct when telling us your suggestion. The only possible technics to establish a communication between Silverlight page and asp.net is by using some web service or javascript. Let us know if you need any further assistance.

On the Page.xaml, I added a Scriptable fuction to be able to be called from JS code later;

public Page()

{

HtmlPage.RegisterScriptableObject("MySilverlightPage", this);

}

[ScriptableMember]

public void CloseRadWindow()

{

this.RadWindow1.Close();

}

And now, to initiate the call to close window from the ASPX source page on the HTMLPlaceHolder that points to a different page than that of the one that holds the Silverlight control (anotherpage.aspx.cs):

Finally, on the other page aspx (anotherpage.aspx), we get access to the silverlight application throught the JS we did on the silverlight page. Once we have access to the SL control, we can call the codebehind function we decorated with [ScriptableMember] tag.

<script type="text/javascript"language="JavaScript1.2">

function CloseSLWindow()

{

var silverlightApplication = parent.GetSilverlightApplication();

silverlightApplication.Content.MySilverlightPage.CloseRadWindow();

}

</script>

You can use this same method for performing any function on silverlight, but initiated through the aspx page. For example, I made another function to display messages in SL:

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.