Вопрос

I have an application where the user clicks a button on the parent window to display a popup window. When the user closes the popup window, how can I determine (in the parent window codebehind) that the user has closed the popup window?

This is the code for closing the popup window:

<script language="javascript" type="text/javascript">
function closeWin() {
    GetRadWindow().Close();
}  
</script>

<asp:Button ID="btnClose" runat="server" Text="Close" 
OnClientClick="closeWin();return false;" onclick="btnClose_Click"/>  
Это было полезно?

Решение

Both RadWindowManager and RadWindow have onClientClose event.

Once RadWindow is closed, OnClientClose will be called. Then you can call parent page's code behind via Ajax or full post back.

Parent Page

<telerik:RadWindowManager .... OnClientClose="clientClose">         
</telerik:RadWindowManager>
OR
<telerik:RadWindow ... OnClientClose="clientClose">
</telerik:RadWindow>

<telerik:RadAjaxManager ... ID="RadAjaxManager1" 
    OnAjaxRequest="RadAjaxManager1_AjaxRequest">
</telerik:RadAjaxManager>

Script inside Parent Page

function clientClose(oWnd, args) {
   // Optional arguments passed from RadWidow
   var arg = args.get_argument(); 

   // Here the example for ajax post back using RadAjaxManager
   $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest(arg);
}

Parent Page Code Behind

protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
   // Argument passed by child window. It is an optional.
   if (e.Argument == "xxx")
   {
      // Do something
   }
}

Updated: to collect the return argument from child window

<script language="javascript" type="text/javascript">
function closeWin(arg) {
    GetRadWindow().Close(arg);
}  
</script>

<asp:Button ID="btnClose" runat="server" Text="Close" 
OnClientClick="closeWin('something');return false;" onclick="btnClose_Click"/> 
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top