Confirm closing of a RadWindow by using radconfirm

Thread is closed for posting
10 posts, 0 answers
  1. 63F75A2C-1F16-4AED-AFE8-B1BBD57646AD
    63F75A2C-1F16-4AED-AFE8-B1BBD57646AD avatar
    1572 posts
    Member since:
    Oct 2004

    Posted 01 Dec 2006 Link to this post

    Requirements

    Article relates to :

    All version of RadWindow for ASP.NET and all versions of RadWindow for ASP.NET AJAX Q32008 and above


    Visual Studio version

    2005/2008

    programming language

    Javascript


     
    PROJECT DESCRIPTION 
    A confirmation dialog in case  the Close button is clicked is useful in cases when you want to prevent the user from accidentally closing the dialog.  

    Bellow we describe two approaches that can be used, according of the version of the RadWindow control.

    RadWindow for ASP.NET AJAX:

    In version 2008.3 13.14 and above we implemented the OnClientBeforeClose event in the control and you can use it in order to achieve the desired functionality. You need to follow the steps bellow :
    • attach a handler to that OnCliendBeforeClose event. This step needs to be when the RadWindow object is created:
      function showBuildSchedule()
      {
          var oWindow = window.radopen("Popup.aspx", "BuildScedulerWindowID");
          oWindow.add_beforeClose(onBeforeClose);
          oWindow.setSize(830, 570);
          oWindow.center();
      }
    • Implement the OnClientBeforeClose handler as follows :
          function onClientBeforeClose(sender, arg)  
          {  
              function callbackFunction(arg)  
              {  
                  if (arg)  
                  {  
                      sender.remove_beforeClose(onClientBeforeClose);  
                      sender.close();  
                  }  
              }  
              arg.set_cancel(true);  
              radconfirm("Are you sure", callbackFunction, 300, 100, null"Close RadWindow");  
          } 
      The OnBeforeClose handler after confirmation the closing.

    RadWindow for ASP.NET :

    In this version the desired result can be achieve by registering to the onclick event of the RadWindow's close button and to call a confirmation dialog there. Depending on the user's answer, you can close the window or leave it as is.

    In the attached project - ASP.NET Classic, we are using a radconfirm dialog. Since it is non-blocking, we also provide a callback function to process the user's reply.
  2. 6E389037-ED88-4DCC-9EBD-1C4DCC5AE8C0
    6E389037-ED88-4DCC-9EBD-1C4DCC5AE8C0 avatar
    27 posts
    Member since:
    Jun 2008

    Posted 14 Jan 2009 Link to this post

    I have tried to set this up on my page and I am getting null error on line 25 of your aspx page

    var CloseButton = document.getElementById("CloseButton" + oWnd.Id);

     

     

    CloseButton.onclick = function()

     

    {

    CurrentWinName = oWnd.Id;

    //radconfirm is non-blocking, so you will need to provide a callback function

    radconfirm("Are you sure you want to close the window?", confirmCallBackFn);

    }

     

     

     

     

    }

    it dies at the part that I have in bold.

     

  3. 93662917-1E03-49EC-9286-033C9D1BF79E
    93662917-1E03-49EC-9286-033C9D1BF79E avatar
    1406 posts
    Member since:
    May 2014

    Posted 14 Jan 2009 Link to this post

    Hi Irish,

    We are not quite sure what is causing the problem in your case - if you use RadWindow for  ASP.NET you should not have a problem. That is why it will be best to send us a full sample project in a new support ticket that reproduces the problem that you experience. Once we have a better view over your scenario and the problems with it, we will do our best to provide a solution.

    Greetings,
    Fiko
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  4. 4BBB931E-1A86-4348-B83B-07A213BBDE4A
    4BBB931E-1A86-4348-B83B-07A213BBDE4A avatar
    14 posts
    Member since:
    Jan 2006

    Posted 29 Jan 2009 Link to this post

    Hi,

    I'm also having a problem with this sample but in a slightly different area:

    For me it crashes a little earlier on the following line:

    var

    CloseButton = document.getElementById("CloseButton" + oWnd.Id);

     


    The problem appears to be that the close button doesn't have an id (I've tried inspecting the dom for the rad window using IE developer tool bar and the close button a tag has a class but no id).
  5. 93662917-1E03-49EC-9286-033C9D1BF79E
    93662917-1E03-49EC-9286-033C9D1BF79E avatar
    1406 posts
    Member since:
    May 2014

    Posted 29 Jan 2009 Link to this post

    Hello Ian,

    You can find two working approaches for RadControls for ASP.NET AJAX (the code here is for RadWindow for ASP.NET) in this forum  thread.

    I hope this helps.

    Regards,
    Fiko
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. 687B735D-948D-4138-8ED7-B77B480B322D
    687B735D-948D-4138-8ED7-B77B480B322D avatar
    14 posts
    Member since:
    Jan 2007

    Posted 15 May 2009 Link to this post


    Hello I just upgraded to version 2009, and in my previous version had this feature, and now no longer works, I need this functionality.
    The CloseButton is null always. 
    what can I do?

    function OpenWindow()

    {

        radopen(

    "http://www.google.com","RadWindow2"); 
        //Make sure to pass the correct window name as  
        //an argument when calling the ConfirmClose() function

     

         

    ConfirmClose("RadWindow2");

     

     

    }

     

    function ConfirmClose(WinName)

    {

     

        var oManager = GetRadWindowManager();

        var oWnd = oManager.GetWindowByName(WinName);

        //Find the Close button on the page and attach to the

     

        //onclick event

     

        var CloseButton = document.getElementById("CloseButton" + oWnd.Id);// Dont work,  CloseButton is null always??

        CloseButton.onclick =

     

            function()

            {

                CurrentWinName = oWnd.Id;

     

                //radconfirm is non-blocking, so you will need to provide a callback function

                radconfirm(

    "Are you sure you want to close the window?", confirmCallBackFn);

     

     

            }
    }

     

     

  7. 93662917-1E03-49EC-9286-033C9D1BF79E
    93662917-1E03-49EC-9286-033C9D1BF79E avatar
    1406 posts
    Member since:
    May 2014

    Posted 19 May 2009 Link to this post

    Hi Ivantkt,

    The code library is updated with a sample for RadWindow for ASP.NET AJAX.

    Best wishes,
    Fiko
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. C01E2D45-B400-4A79-B315-9BE362E74E9D
    C01E2D45-B400-4A79-B315-9BE362E74E9D avatar
    107 posts
    Member since:
    Nov 2007

    Posted 26 Aug 2010 Link to this post

    Hello

    Here is a typo in the code library confirmclosing-ajax.zip:
       oWindow.add_beforeClose(onBeforeClose);
    should be changed to:
      oWnd.add_beforeClose(onBeforeClose);

    Regards,
    Tonino.
  9. C01E2D45-B400-4A79-B315-9BE362E74E9D
    C01E2D45-B400-4A79-B315-9BE362E74E9D avatar
    107 posts
    Member since:
    Nov 2007

    Posted 26 Aug 2010 Link to this post

    Hello again!

    Is there a way to handle the close-window-event in Popup.aspx?

    Regards,
    Tonino.
  10. 93662917-1E03-49EC-9286-033C9D1BF79E
    93662917-1E03-49EC-9286-033C9D1BF79E avatar
    1406 posts
    Member since:
    May 2014

    Posted 30 Aug 2010 Link to this post

    Hi Tonino,

    Thank you for the feedback. I have updated the confirmclosing-ajax.zip project in the code library.

    I believe that this code library is exactly what you need.

    Regards,
    Fiko
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.