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

OnClientClose event never executed!!

3 Answers 69 Views
Window
This is a migrated thread and some comments may be shown as answers.
Arash Rahimian
Top achievements
Rank 1
Arash Rahimian asked on 29 Jun 2010, 01:13 PM
I wrote this code for opening a dialog for displaying my confirmation dialog but when I click on yes button my return method will be executed but OnClientClose never been executed?
I wrote 2 user control. first one is my main message box control that contain RadWindowManager and a hidden ButtonYes. In second one I will shown my message and my Yes button (MessageBoxContainer user control). In my strategy when you click on yes button on MessageBoxContainer control message box will be closed and return an argument to MessageBox control and it must execute OnClientClose function for clicking on hidden ButtonYes but OnClientClose never be executed!! Here is my code.

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MessageBox.ascx.cs" Inherits="Diten.Web.AspNet.UI.UserControls.MessageBox" Debug="true" %>
<script type="text/javascript">
    function openWin(url, windowID) {
        var parentPage = GetRadWindow().BrowserWindow;
        var parentRadWindowManager = parentPage.GetRadWindowManager();
        var oWnd = parentRadWindowManager.open(url, windowID);
        window.setTimeout(function () {
            oWnd.setActive(true);
        }, 0);
    }

    function OnClientClose(oWnd, args) {
        alert('Parent: ' + arg.clikedButton);
        var arg = args.get_argument();

        if (arg) {
            if (arg.clikedButton == 'Ok') {
                document.getElementById('<%= this.ButtonOk.ClientID %>').click();
            } else if (arg.clikedButton == 'Cancel') {
                document.getElementById('<%= this.ButtonCancel.ClientID %>').click();
            } else if (arg.clikedButton == 'Retry') {
                document.getElementById('<%= this.ButtonRetry.ClientID %>').click();
            } else if (arg.clikedButton == 'Abort') {
                document.getElementById('<%= this.ButtonAbort.ClientID %>').click();
            } else if (arg.clikedButton == 'Yes') {
                document.getElementById('<%= this.ButtonYes.ClientID %>').click();
            } else if (arg.clikedButton == 'No') {
                document.getElementById('<%= this.ButtonNo.ClientID %>').click();
            }
        }
    }
</script>
<telerik:RadWindowManager ID="RadWindowManager" runat="server" OnClientClose="OnClientClose" Behaviors="Close, Move" VisibleStatusbar="false" AutoSize="true" ShowContentDuringLoad="false" DestroyOnClose="true" >
</telerik:RadWindowManager>
<asp:Button ID="ButtonOk" runat="server" Text="Ok" onclick="ButtonOk_Click" style="display:none;" />
<asp:Button ID="ButtonCancel" runat="server" Text="Cancel" onclick="ButtonCancel_Click" style="display:none;" />
<asp:Button ID="ButtonRetry" runat="server" Text="Retry" onclick="ButtonRetry_Click" style="display:none;" />
<asp:Button ID="ButtonAbort" runat="server" Text="Abort" onclick="ButtonAbort_Click" style="display:none;" />
<asp:Button ID="ButtonYes" runat="server" Text="Yes" onclick="ButtonYes_Click" style="display:none;" />
<asp:Button ID="ButtonNo" runat="server" Text="No" onclick="ButtonNo_Click" style="display:none;" />




MessageBox show method

        public void Show(string message, MessageBoxModes messageBoxMode, MessageBoxIcon messageBoxIcon, string eventHandlerID, bool isModal)
        {
            message = message.Replace("%n", "<br/>");

            string _parameters = "ControlToLoad=Diten.Web.AspNet.UI.UserControls.MessageBoxContainer" + "&OpenerID=" + this.OpenerID + "&Message=" + message +
                "&MessageBoxMode=" + ((int)messageBoxMode).ToString() + "&MessageBoxIcon=" + ((int)messageBoxIcon).ToString() +
                "&MessageBoxEventHandlerID=" + eventHandlerID;
           
            string _navigateUrl = "/MainFrame.aspx?EncParameters=" + this.Encrypt(_parameters) + "', '" + this.Translate("Message");

            RadWindow _radWindow = new RadWindow();
            _radWindow.ID = "RadWindow" + Guid.NewGuid().ToString().Replace("-", string.Empty);
            _radWindow.Behaviors = WindowBehaviors.Close;
            _radWindow.Modal = isModal;
            _radWindow.NavigateUrl = _navigateUrl;
            _radWindow.Animation = WindowAnimation.Fade;
            _radWindow.OnClientClose = "OnClientClose";

            this.RadWindowManager.Windows.Add(_radWindow);

            string _javaScript = string.Empty;

            if (!isModal)
                _javaScript = "radopen('" + _navigateUrl + "', '" + _radWindow.ID + "');";
            else
                _javaScript = "openWin('" + _navigateUrl + "', '" + _radWindow.ID + "');";

            RadScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), this.ClientID + "MessageBox", _javaScript, true);
        }



MessageBoxContainer ASCX code

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MessageBoxContainer.ascx.cs" Inherits="Diten.Web.AspNet.UI.UserControls.MessageBoxContainer" Debug="true" %>
<%@ Register Src="~/UI/UserControls/Templates/GroupBox.ascx" TagPrefix="DitenAsp" TagName="GroupBox" %>
<script language="javascript">
    function returnToParent(clikedButton) {
        var oArg = new Object();
        var oWnd = GetRadWindow();

        oArg.clikedButton = clikedButton;
        oWnd.close(oArg);
    }
</script>
<table cellpadding="0" cellspacing="0" width="100%" style="vertical-align: top;">
    <tr>
        <td align="center" width="100%" style="vertical-align: top;">
            <table cellpadding="0" cellspacing="0" width="100%" style="vertical-align: top;">
                <tr>
                    <td style="vertical-align: top; padding-right: 5px;">
                        <asp:Image ID="ImageIcon" runat="server" Width="32px" Height="32px" />
                    </td>
                    <td style="vertical-align: middle; text-align: left;" wrap="nowrap" nowrap>
                        <DitenAsp:GroupBox ID="GroupBox" runat="server">
                            <ContentTemplate>
                                <asp:Label ID="LabelMessage" runat="server" Text="Label"></asp:Label>
                            </ContentTemplate>
                        </DitenAsp:GroupBox>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td align="center" width="100%" style="height: 33px;">
            <asp:PlaceHolder ID="PlaceHolderButtons" runat="server"></asp:PlaceHolder>
        </td>
    </tr>
</table>



i'm adding ButtonYes and RadWindow dynamically into my controls. Now my question is how could I execute OnClientClose method by calling OnClientClose event of my RadWindowManager or my RadWindow?

3 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 01 Jul 2010, 11:03 AM
Hello Arash,

The code that you posted looks OK and at this point I cannot tell what the reason for the problem might be. If you still experience this problem, please open a support ticket and send us a small sample project where the problem could be reproduced so we could investigate further.

Greetings,
Georgi Tunev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Arash Rahimian
Top achievements
Rank 1
answered on 04 Jul 2010, 02:08 PM
Thanks for  you attention. my first problem is solved but another problem happened!! when I open 6 window (window 6 is opened by window 5 and window 5 is opened by window 4 etc.), when I click on ok button for closing window 6 all odd number windows will be closed!! for example if I close window 6, window 1,3 and 5 will be closed too!??!!! I understand when OnClientClose event on window 6 called, all odd number windows will be closed. how can I solve this problem?
another problem is when I use my window user control for opening a RadWindow, after closing window OnClientClose method of first window control will be called but I put a unique RadWindowManager for each window control.
0
Georgi Tunev
Telerik team
answered on 07 Jul 2010, 11:23 AM
Hello Arash,

I am afraid that I was not able to understand completely your scenario. Please open a support ticket and send a sample project so we could investigate. Once we have a better view over your case, we will do our best to provide a solution right away.

Best wishes,
Georgi Tunev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Window
Asked by
Arash Rahimian
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Arash Rahimian
Top achievements
Rank 1
Share this question
or