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

confirm if radwindow must be close. (Showing a radconfirm on close of a window )

3 Answers 229 Views
Window
This is a migrated thread and some comments may be shown as answers.
nenita
Top achievements
Rank 1
nenita asked on 02 Apr 2009, 07:12 PM
Hi, me again, I need to do the same like its exposed on the forum:
some similar
but I have different mistakes, this is the scenario:



function onBeforeClose(sender, arg)  
{  
    function callbackFunction(arg)  
    {  
        if (arg)  
        {  
            sender.remove_beforeClose(onBeforeClose);  
            sender.close();  
        }  
    }  
arg.set_cancel(true);  
radconfirm("Are you sure", callbackFunction, 300, 100, null"Close RadWindow");  
}  
//this function call a window when I click a menu item 
function menuClick(sender,arg)  
{    
//show window .... 
//.... 
//this comment lines not work, I try both 
//wnd.add_beforeClose(onBeforeClose);  
//sender.add_beforeClose(onBeforeClose);  
 
//but this work. its a closing event not before close 
wnd.add_close(onBeforeClose); 
}  

and when i close this its the message error: arg.set_cancel is not a function,
I  read on the forum something like if its no the right method this error shows but, 'add_beforeClose' dont work to me yet.
there another way to call this event?
I'm a litle confused.
    
    Thanks in advance.
    Nenita.*

3 Answers, 1 is accepted

Sort by
0
nenita
Top achievements
Rank 1
answered on 03 Apr 2009, 04:59 PM
I solve a litle piece of my problem. I do the following
include a jquery script and  found the class called when I click the close button because this dont have Id its something like this:
I adapt one example from here:
http://www.telerik.com/community/code-library/aspnet-ajax/window/confirm-closing-of-a-radwindow-by-using-radconfirm.aspx



        function OpenWindow(sender, eventArgs) 
        { 
            radopen("http://www.google.com","RadWindow2");  
            //Make sure to pass the correct window name as  
            //an argument when calling the ConfirmClose() function 
             
            ConfirmClose("RadWindowWrapper"+"_"+"RadWindow2",sender,eventArgs); 
        } 
        
        function ConfirmClose(WinName,sender,eventArgs) 
        { 
            var oManager = GetRadWindowManager();            
            var oWnd = oManager.GetWindowByName(WinName); 
            var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");     
         
             
            $("a.closebutton").click(function(){ 
            // prompt box code 
                alert('x');                 
                eventArgs.set_cancel(true);//dont work. 
                radconfirm("Are you sure", confirmCallBackFn, 300, 100, null"Cerrar Ventana?");  
                //cancelar cierre de ventana 
                 
                 
            }); 
             
        } 
         
        function confirmCallBackFn(arg) 
        { 
            if (arg == true
                {    
                     
                    var oManager = GetRadWindowManager(); 
                    var oWnd = oManager.GetWindowByName(CurrentWinName); 
                    oWnd.Close(); 
                } 
        }  
      

but my problem now its the argument come empty, I dont kwon well how to request them.
I found this code maybe generate automaticly  inside my page I think if I know well what are the parameter maybe I can stop the close execution  RadAjaxRequestEventArgs seems to request the arguments and later cancels, but I dont kwon really well.

var evt=new Telerik.Web.UI.RadAjaxRequestEventArgs(this.__EVENTTARGET,_23._form["__EVENTARGUMENT"].value,this._enableAJAX); 
var _2b=this.fireEvent(this,"OnRequestStart",[evt]); 
if(evt.get_cancel()||(typeof (_2b)!="undefined"&&!_2b)){ 
_24.set_cancel(true); 

There are any function to overwrite like when we try to change the appereance skin?

By any help Thanks in advance.
Nenita.
pd: sorry for my english
0
nenita
Top achievements
Rank 1
answered on 03 Apr 2009, 09:34 PM
I progress a litle, using Jquery, replace many atributes from the button,
1. I remove the span tag inside a.closebutton 
2. I replace the href atribute: before: javascript:void(0); later:""
3. I change the name of the button and put them "cerrar"
4. put in my css a new class for the new button.

before:
<li> 
<class="closebutton" href="javascript:void(0);" title="Close"
<span>Close</span> 
</a> 
</li> 

later: I see this using an inspector,  this is the result:
<class="cerrar" href="" title="cerrar" onclick="javascript:cerrar();"/> 

but anyway when I click the result its the same -> close the window.

inside my code I found this:
<div> 
                <a  onclick="$find('{0}').close();" 
                class="radwindowbutton" href="javascript:void(0);"
                    <span class="outerspan"
                        <span class="innerspan">##LOC[OK]##</span> 
                    </span> 
                </a>                 
            </div> 
 

it's that the problem?

Any idea its helpful.
Very thank you in advance.

Nenita.
0
Svetlina Anati
Telerik team
answered on 06 Apr 2009, 12:22 PM
Hi nenita,

Your initial approach should work in the common case - I prepared for you a sample demo based on it which works as expected - please see the attached demo. One possible problem could be that you are using a very old version of RadWindow where the OnClientBeforeShow event is still not implemented (the event is introduced in the 2008.3.1314 release). If so, I suggest to upgrade to the latest release. If this is the case and you do not want to upgrade, you can override the default close function as shown below:

http://www.telerik.com/community/forums/aspnet-ajax/window/close-the-rad-window.aspx

In case you are using a later version than the mentioned one, please examine the attached demo which I prepared for you - just modify it in order to reproduce the problem, open a new support ticket and send it to me along with detailed reproduction steps and explanations.

Kind regards,
Svetlina
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Window
Asked by
nenita
Top achievements
Rank 1
Answers by
nenita
Top achievements
Rank 1
Svetlina Anati
Telerik team
Share this question
or