Save before close radwindow ?

2 posts, 0 answers
  1. Madhu Palakurthi
    Madhu Palakurthi avatar
    48 posts
    Member since:
    Nov 2009

    Posted 07 Jul 2013 Link to this post


    I have email ( compose screen ) is showing in the radwindow as popup. If user clicks on close button accidentally then I would like to show radconfirm.

    Now I can able to show radconfirm ( "Do you want to save as draft ") , But 2 things i have to do.
    1) Have check validation before save.
    2) If user clicks on "OK" then i would like to save as draft.

    In Parent :

    <telerik:RadWindowManager runat="Server" ID="RadWindowManager2" ShowContentDuringLoad="false"
            <telerik:RadWindow runat="server" ID="EmailScreen" KeepInScreenBounds="true" Title="TWDM Email"
                OnClientBeforeClose="OnClientBeforeCloseEmailScreen" InitialBehaviors="Maximize"
                AutoSize="true" Width="1000px" Height="850px" ReloadOnShow="true" ShowContentDuringLoad="false"
                Modal="True" Behaviors="Close,Move,Resize,Maximize" VisibleStatusbar="true">
      function OnClientBeforeCloseEmailScreen(sender, eventArgs) {
                radconfirm('Do you want to save as draft?', confirmCallbackFn1, 400, 200, null, 'TWDM Confirm');
            function confirmCallbackFn1(arg) {
                if (arg) //the user clicked OK
                    __doPostBack("<%=hdnBtnSaveAsDraft.UniqueID %>", "");
    ' Showing email compose screen in Radwindow Popup here.
     function onButtonClicked(sender, args) {
                var commandName = args.get_item().get_commandName();
                var qs = getQueryStrings();
                var oManager = GetRadWindowManager().getWindowByName("EmailScreen");
               if (commandName == "Compose") {
                    window.radopen("ComposeMail.aspx?type=NewEmail&TaskNo=" + qs["TaskNo"] + "&Parent=" + qs["Parent"] + "", "EmailScreen");

    Find the attachment and Please help me on this..

  2. Ivaylo
    Ivaylo avatar
    37 posts

    Posted 08 Jul 2013 Link to this post

    Hello Narsa,

    Thank you for your question.

    I have already answered the support ticket you have opened regarding the same topic. For convenience I am also attaching my response here.

    In order to achieve the desired behavior, a few modifications to the code would need to be introduced. I have illustrated the needed changes below and have also attached a sample project for your convenience.

    First of all, you will need to set the ShowOnTopWhenMaximized property of the RadWindow to False, so that the RadConfirm Dialog shows in front of the E-mail window:

    <telerik:RadWindow runat="server" ID="EmailScreen" ShowOnTopWhenMaximized="false" ...>

    Next, I have modified the OnClientBeforeClseEmail function and have added an additional argument to it to check if it was called manually from the code, or was triggered as a result of the user's attempt to close the window. The reason for this validation is that the callback function of RadConfirm does not stop the execution of the rest of the JavaScript code, meaning that at the moment of calling RadConfirm, the window will close, when we need it to wait for the user interaction:
    function OnClientBeforeCloseEmailScreen(sender, eventArgs) {
        //additional argument which will exist only if the function was
        //called programmatically
        arg = eventArgs.get_argument();
        if (arg) {
            //closed manually from confirmCallbackFn1 - no need to validate
        else {
            //call radconfirm
            radconfirm('Do you want to save as draft?', confirmCallbackFn1, 400, 200, null, 'TWDM Confirm');
            //cancel event so that the user response is handled.

    Last, but not least
    , in case the user clicked OK in the radConfirm dialog confirmCallbackFn1 is called, a postback is made and the E-mail Window is closed. Else, nothing happens:
    function confirmCallbackFn1(arg){
        if (arg) //the user clicked OK
            //do post back
            //__doPostBack("<%'=hdnBtnSaveAsDraft.UniqueID%>", "");
            //close the window (with the additional argument)
        else alert("Close cancelled.")

    Please find attached a sample project with all the modifications mentioned above. Feel free to alter it, so that it meets the requirements of your project.

    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. DevCraft R3 2016 release webinar banner
Back to Top