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

warn radwindow close.

1 Answer 30 Views
Window
This is a migrated thread and some comments may be shown as answers.
Damian
Top achievements
Rank 1
Damian asked on 29 Aug 2013, 05:49 PM
Hi

I am opening a radwindow on a radbutton click which opens an edit form to the user. There are save and cancel buttons inside the window. I wrote the code to warn the user if he attempt to close the radwindow without save. I want to do the same if the user  press the back button and try to go back to previous page. Any suggestions?

Thanks
Damian

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 30 Aug 2013, 04:20 AM
Hi Damian,

Please try the following code to display a browser alert on pressing the back button.

ASPX:
<telerik:RadButton ID="RadButton1" runat="server" Text="Open Edit Form">
</telerik:RadButton>
<telerik:RadWindow ID="RadWindow1" runat="server" Modal="true" Behaviors="None" Width="400px"
    Height="400px" OpenerElementID="RadButton1" OnClientShow="OnClientShow">
    <ContentTemplate>
        <div style="padding: 15px 10px 10px 25px;">
            <telerik:RadTextBox ID="RadTextBox1" runat="server" Label="No :">
            </telerik:RadTextBox>
            <br />
            <telerik:RadTextBox ID="RadTextBox2" runat="server" Label="Name :">
            </telerik:RadTextBox>
            <br />
            <telerik:RadButton ID="RadButton2" runat="server" Text="Save" OnClientClicked="OnClientClicked"
                OnClick="RadButton2_Click">
            </telerik:RadButton>
            <telerik:RadButton ID="RadButton3" runat="server" Text="Cancel">
            </telerik:RadButton>
        </div>
    </ContentTemplate>
</telerik:RadWindow>

JavaScript:
<script type="text/javascript">
    function OnClientShow(sender, args) {
        window.onbeforeunload = function () { return "Unsaved data will be lost."; };
    }
    function OnClientClicked(sender, args) {
        window.onbeforeunload = null;
    }
</script>

Thanks,
Shinu.
Tags
Window
Asked by
Damian
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or