warn radwindow close.

2 posts, 0 answers
  1. Damian
    Damian avatar
    21 posts
    Member since:
    Mar 2013

    Posted 29 Aug 2013 Link to this post

    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
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 29 Aug 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top