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

RadWindow confirm close handling

2 Answers 208 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Steve Holdorf
Top achievements
Rank 1
Steve Holdorf asked on 09 Dec 2010, 06:00 PM
I have a RadWindow that has a custom button that performs a save and close. This works fine. Now, what I am trying to do is display a javascript close confirm dialog when the user selects the top right close X button. I saw the article about the radConfirm method and adding add_beforeClose(onBeforeClose) techniques. In my case I have had no luck with either. Can you recommend a way to do this?

Thanks,


Steve Holdorf

2 Answers, 1 is accepted

Sort by
0
Steve Holdorf
Top achievements
Rank 1
answered on 09 Dec 2010, 10:00 PM
I found your example (see below) but am getting the javascript runtime error: Object expected on the radConfirm call.


<script type="text/javascript">

  function onBeforeWindowClose(oWinow, args)
  {
   function callbckFunction(confirmResult)
   {
    if (confirmResult)
    {// confirmResult == true
     // Close this RadWindow

     // First remove the handler in order to avoid recursion
     oWinow.remove_beforeClose(onBeforeWindowClose);

     // Close the window
     oWinow.close();

     // Reattach the handles after the window is closed.
     // RECOMMENDATION: If the DestroyOnClose="true" property is set in in the RadWindow's declaration,
     // then remove this line of the code:
      oWinow.add_beforeClose(onBeforeWindowClose);
    }
    else
    {// confirmResult == false
     radalert("Closing is canceled");
    }
   }

   // Cancel closing
   args.set_cancel(true);

   // Show a rad confirmation dialog
   radconfirm("Are you sure ?", callbckFunction, 400, 200, null, "Rad Confirm");
  }

  function GetRadWindow()
  {
   var oWindow = null;
   if (window.radWindow)
    oWindow = window.radWindow;
   else if (window.frameElement.radWindow)
    oWindow = window.frameElement.radWindow;
   return oWindow;
  }

  function pageLoad()
  {
   // Get the RadWindoiw object that contains this page
   var oWindow = GetRadWindow();

   // Attach RadWindow's OnClientBeforeClose handler
   oWindow.add_beforeClose(onBeforeWindowClose);
  }

  function pageUnload()
  {
   // Get the RadWindoiw object that contains this page
   var oWindow = GetRadWindow();

   // NOTE! If the DestroyOnClose="true" is set in the RadWindow's declaration,
   // then the oWindow object will be 'null'.
   if (oWindow)
   {
    // Detach RadWindow's OnClientBeforeClose handler
    oWindow.remove_beforeClose(onBeforeWindowClose);
   }
  }

</script>
0
Accepted
Georgi Tunev
Telerik team
answered on 11 Dec 2010, 12:34 PM
Hello Steve,

If you need to call radconfirm(), radalert(), radopen(), etc. RadWindowManager's functions, you must have a RadWindowManager control present on the page where the script is executed.

Regards,
Georgi Tunev
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Editor
Asked by
Steve Holdorf
Top achievements
Rank 1
Answers by
Steve Holdorf
Top achievements
Rank 1
Georgi Tunev
Telerik team
Share this question
or