RadWindow Unsaved Changes

3 posts, 0 answers
  1. Michele
    Michele avatar
    4 posts
    Member since:
    Apr 2012

    Posted 21 Aug 2012 Link to this post

    I am using Telerik ASP.NET AJAX Version 2012.1.411.40.  I have a page  where the user enters some search criteria and the search results are returned and displayed in a radGrid on the page.  If the entry in the grid is editable, an edit pencil is displayed. When the user clicks the edit pencil, a custom edit form is displayed in a radWindow. This window is opened from the codebehind (I need to pass several values to the edit form so that I know which record I need to edit) in the OnClick event handler using the following code:

    rwinEditCustomer.Modal =




    rwinEditCustomer.NavigateUrl =


    String.Format("CustomerAddEdit.aspx?source={0}&addrid={1}&cntctid={2}", lblSource.Text, hdnAddressId.Value, hdnContactId.Value);




    string script = "function f(){$find(\"" + rwinEditCustomer.ClientID + "\").show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";




    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "winEditCust", script, true);


    Buttons are available on the edit form for the user to delete the entry, save the information, or cancel.  If the user clicks delete, I use radconfirm to display a confirmation message. If the user choses to continue with the delete, the record is deleted, the radwindow is closed and the radgrid is rebound. If the user clicks save, the information is saved, the radwindow is closed and the radgrid is rebound.  If the user clicks cancel, the radwindow is closed. That all seems to be working. Now  I need to detect if the user changed any information. If data has been changed, I need to use radconfirm to warn the user about unsaved changes if they click cancel or try to close the edit window. I don't want to warn the user if they click save or if they close the edit window without changing any information.  I've searched through the forums for guidance but haven't been able to connect the dots to get this to work the way I need it to.  At one point, I had it working where I got a valid unsaved changes warning (not using radconfirm though) when the cancel was clicked. But when I tried to close the edit window, the radwindow closed and then displayed the warning which is not the order I'm looking for. 

    Any suggestions on how I can do this?

  2. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 22 Aug 2012 Link to this post

    Hello Michele,

    One approach would be to add a hidden field to your RadWindow page that would be used to determine if the RadWindow should be prevented from closing. Then you can handle the OnClientBeforeClose event and check the hidden field to determine if the RadWindow should close.

    So something like so:

    function OnClientBeforeClose(sender, args) {
        var hdnPreventClose = $get("hdnPreventClose", sender.get_contentFrame());
        if (hdnPreventClose.value == "true") {

    I would suggest using a standard html hidden field, instead of an asp:HiddenFIeld, so that you can find the control easier since the ID will be simpler to add.

    Also, in your RadWindow, you can then call the RadConfirm and during it's callback method, you can update the hidden field by passing "false" and then close the window if the user does not want to save the changes.

    I hope that helps.
  3. Michele
    Michele avatar
    4 posts
    Member since:
    Apr 2012

    Posted 22 Aug 2012 Link to this post

    Thanks so much for the suggestion. I will try it out as soon as I can and let you what happened. I was switched to another project so I may not get to try this until next week.  Thanks again.
Back to Top