Skip Navigation LinksHome / Community & Support / Code Library / ASP.NET AJAX > Window > Confirm closing of a RadWindow by using radconfirm

Confirm closing of a RadWindow by using radconfirm

Feed from this thread
  • Posted on Dec 1, 2006 (permalink)

    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.

    Reply

  • IrishManInUSA avatar

    Posted on Jan 14, 2009 (permalink)

    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.

     

    Reply

  • Fiko Fiko avatar

    Posted on Jan 14, 2009 (permalink)

    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.

    Reply

  • ian webster avatar

    Posted on Jan 29, 2009 (permalink)

    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).

    Reply

  • Fiko Fiko avatar

    Posted on Jan 29, 2009 (permalink)

    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.

    Reply

  • Posted on May 15, 2009 (permalink)


    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);

     

     

            }
    }

     

     

    Reply

  • Fiko Fiko avatar

    Posted on May 19, 2009 (permalink)

    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.

    Reply

  • Tonino Intermediate avatar

    Posted on Aug 26, 2010 (permalink)

    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.

    Reply

  • Tonino Intermediate avatar

    Posted on Aug 26, 2010 (permalink)

    Hello again!

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

    Regards,
    Tonino.

    Reply

  • Fiko Fiko avatar

    Posted on Aug 30, 2010 (permalink)

    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.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Code Library / ASP.NET AJAX > Window > Confirm closing of a RadWindow by using radconfirm