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

Save before close radwindow ?

1 Answer 224 Views
Window
This is a migrated thread and some comments may be shown as answers.
Madhu Palakurthi
Top achievements
Rank 1
Madhu Palakurthi asked on 08 Jul 2013, 02:25 AM
Hi,

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"
    EnableViewState="false">
    <Windows>
        <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">
        </telerik:RadWindow>
    </Windows>  
</telerik:RadWindowManager>
 
  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..





1 Answer, 1 is accepted

Sort by
0
Ivaylo
Telerik team
answered on 08 Jul 2013, 11:13 AM
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" ...>
</telerik:RadWindow>

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.
        eventArgs.set_cancel(true);
    }
}

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)
        GetRadWindowManager().getWindowByName("EmailScreen").close(true);
    }
    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.


Regards,
Ivaylo
Telerik
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.
Tags
Window
Asked by
Madhu Palakurthi
Top achievements
Rank 1
Answers by
Ivaylo
Telerik team
Share this question
or