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

When Rad Window closed or user moves away from the window , need to show alert message Are you sure want to leave?

1 Answer 36 Views
Window
This is a migrated thread and some comments may be shown as answers.
Joselina
Top achievements
Rank 1
Joselina asked on 28 Feb 2014, 07:18 PM
Hi,

I am opening a page to add some document data through a window, and i need to popup the alert "Are you sure want to leave this page?" when ever the user close this window or moves the cursor away from the window or clicks anywhere else other than window. Can you please help me how to show this alert message?
1.This window opens up by clicking the sub menu items from the menu items list. 
2. I want to show this alert only when i click the Add menu item -> Submenu items
3.I should not show the alert when i click Replace or any other menu items in that menu list.
4. Onemore thing this page already has the below Alert function and it is working fine when I am opening the same page in different location in a normal way but not in window mode.
This is the Javascript Function for the Alert
 
function windowOnBeforeUnload() {
 
        if (window.event)
            window.event.returnValue = 'You will lose any unsaved changes!'; // IE
        else
            return 'You will lose any unsaved changes!'; // FX
    }
 
This is the RadMenu HTML code
<table class="takeActionTableContainer" cellpadding="1" cellspacing="0" style="margin: 0 auto;">
    <tr>
        <td style="vertical-align:top; text-align:center; width:50%">
            <telerik:RadMenu ID="RadMenuLibrary" runat="server" EnableRoundedCorners="true" EnableShadows="true" Skin="Default" EnableTextHTMLEncoding="true" Width="100%"
                style="z-index:10; position: relative; margin: 0; text-align:center;" DefaultClickToOpen="False" CollapseDelay="200" ExpandDelay="200" OnClientItemClicked="OnTakeActionItemClicked" OnClientItemClosed="windowOnBeforeUnload" OnClientMouseOut="windowOnBeforeUnload" >
                <ExpandAnimation Type="None" Duration="200" />
                <CollapseAnimation Type="None" Duration="200" />
                <Items>
                    <telerik:RadMenuItem runat="server" Text="LIBRARY" PostBack="false" Width="100%"></telerik:RadMenuItem>
                </Items>
            </telerik:RadMenu>
        </td>
        <td style="vertical-align:top; text-align:center; width:50%">
            <telerik:RadMenu ID="RadMenuCollaborator" runat="server" EnableRoundedCorners="true" EnableShadows="true" Skin="Default" EnableTextHTMLEncoding="true" Width="100%"
                style="z-index:10; position: relative; margin: 0; text-align:center;" DefaultClickToOpen="False" CollapseDelay="200" ExpandDelay="200" OnClientItemClicked="OnTakeActionItemClicked" >     
                <ExpandAnimation Type="None" Duration="200" />
                <CollapseAnimation Type="None" Duration="200" />
                 <Items>
                    <telerik:RadMenuItem runat="server" Text="COLLABORATOR" PostBack="false" Width="100%"></telerik:RadMenuItem>
                </Items>
            </telerik:RadMenu>
        </td>
    </tr>

I have called the alert function in OnClientItemClicked but i dont want this alert to be displayed when other menu items are clicked.

Thanks
Joselina

1 Answer, 1 is accepted

Sort by
0
Joselina
Top achievements
Rank 1
answered on 28 Feb 2014, 07:20 PM
sorry not in onclientclicked , but i called in OnClientItemClosed="windowOnBeforeUnload" OnClientMouseOut="windowOnBeforeUnload"
Tags
Window
Asked by
Joselina
Top achievements
Rank 1
Answers by
Joselina
Top achievements
Rank 1
Share this question
or