how to close radwindow without refreshing parent

Azi picture Azi · Jul 8, 2011 · Viewed 16k times · Source

I have a parent page that launches a telerik radwindow. Every thing works well. My problem is when the radwindow closed, the parent reload again. I don't want this. how can I close radwin

Once the radwindow is done processeing the value, I need it to return it to the parent page, and I would like the parent page to have access to this value in my code behind page.

Answer

Win picture Win · Jul 13, 2011

Parent ASPX:

<telerik:RadWindowManager ID="RadWindowManager1" runat="server" DestroyOnClose="true" Width="750px" Height="500px" OnClientClose="onClientClose">
    <windows>
<telerik:RadWindow ID="RadWindow1" runat="server">
</telerik:RadWindow>
    </windows>
</telerik:RadWindowManager>
<%-- RadAjaxManager --%>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
    <ajaxsettings>
<telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
    <UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadAjaxManager1" />
<telerik:AjaxUpdatedControl ControlID="RadGrid1" />
    </UpdatedControls>
</telerik:AjaxSetting>       
    </ajaxsettings>
</telerik:RadAjaxManager>

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

    <script type="text/javascript">

// Insert in RadWindow
function showForm(url) {
    window.radopen(url, "RadWindow1");
    return false;
}


function onClientClose(oWnd, args) {
    // get the transferred arguments
    var arg = args.get_argument();
    if (arg == '' || arg == null) {
// No need to refresh RadGrid
    }
    else {
$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest(arg);
    }
}


    </script>

</telerik:RadCodeBlock>

Parent Code Behind:

protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
    var result = Int32.Parse(e.Argument); // return argument from child
}

Child ASPX

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

<script type="text/javascript">

    //mandatory for the RadWindow dialogs functionality
    function getRadWindow() {
    if (window.radWindow) {
        return window.radWindow;
    }
    if (window.frameElement && window.frameElement.radWindow) {
        return window.frameElement.radWindow;
    }
    return null;
    }

    // Fires when the changes are saved
    function onClientClose(arg) {
        // Pass the arguments from the dialog to the callback function on the main page.    
        getRadWindow().close(arg);
    }
    </script>

</telerik:RadCodeBlock>

Child code behind

protected void ChildSave_Click(object sender, EventArgs e)
{

    ClientScriptManager cs = Page.ClientScript;

    cs.RegisterStartupScript(typeof(Page), "CloseScript_" + UniqueID,
      "onClientClose('1');", true); // Return value 1 to parent

}