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

Too much old samples for RadConfirm with RadWindow

5 Answers 123 Views
Window
This is a migrated thread and some comments may be shown as answers.
CSurieux
Top achievements
Rank 2
CSurieux asked on 30 Oct 2008, 08:48 AM
Hello,

I spent hours trying to find what is the good sample to use when you want to add a confirm script to button or anchors using RadWindow.

On buttons I use:
string js = string.Format("return radconfirm('{0}', event, null, null,null,'{1}');", msg, title);
if ( Btn.Attributes["onclick"] != null)
      Btn.Attributes["onclick"] = js;
else Btn.Attributes.Add("onclick",js);

I found a sample on forums which seems to be related to previous RadControls, not for AJX.NET and I got problems when the button is using call back.

This sample is based on following script.
function ConfirmLoadHandler()   
{  
var oldConfirm = radconfirm;     
 //We will change the radconfirm function so it takes all the original radconfirm attributes  
window.radconfirm = function(text, mozEvent, oWidth, oHeight, callerObj, oTitle)     
{     
    var ev = mozEvent ? mozEvent : window.event; //Moz support requires passing the event argument manually     
    //Cancel the event     
    ev.cancelBubble = true;     
    ev.returnValue = false;     
    if (ev.stopPropagation) ev.stopPropagation();     
    if (ev.preventDefault) ev.preventDefault();     
         
    //Determine who is the caller     
    var callerObj = ev.srcElement ? ev.srcElement : ev.target;     
 
    //Call the original radconfirm and pass it all necessary parameters     
    if (callerObj)      
    {     
        //Show the confirm, then when it is closing, if returned value was true, automatically call the caller's click method again.     
        var callBackFn = function (arg)     
        {                
            if (arg)     
            {                
                callerObj["onclick"] = "";               
                if (callerObj.click) callerObj.click(); //Works fine every time in IE, but does not work for links in Moz     
                else if (callerObj.tagName == "A"//We assume it is a link button!     
                {                                                            
                    try    
                    {     
                        eval(callerObj.href)     
                    }     
                    catch(e){}     
                }     
            }     
        }     
        //We will need to modify the oldconfirm as well ????????  
        oldConfirm(text, callBackFn, oWidth, oHeight, callerObj, oTitle);   
    }     
    return false;     
    }   
}  
 
I don't need this script on each page and I use a registerConfirm method in codebehind to insert it.
But this script should be called after RadWindowManager declaration, so I use following code to add it on the last instructions of the page:
string scrpt  =   "ConfirmLoadHandler();";
AjaxManager.ResponseScripts.Add(scrpt);

And I get problems on callback: I am fearing the radconfirm function is replaced many times ? How to control this.

Is there a more recent sample we could use with last 2.1001 version to have a safely confirm with radWindows.

Thanks for clarification.

CS

5 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 04 Nov 2008, 08:42 AM
Hi Christian,

The code that you posted (here is the original Code Library thread) hasn't been changed and is working for both RadWindow for ASP.NET and RadWindow for ASP.NET AJAX. If you still experience problems, please open a support ticket an send us a sample project where they can be reproduced - we will check it and do our best to help.



Best wishes,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
CSurieux
Top achievements
Rank 2
answered on 04 Nov 2008, 10:25 AM
Hello Georgi,

Thanks for answer, I will take time to create a test project and submit it in a ticket, but my framework being linked to another huge product needding licenses and long install, it take much more time to do this, having to rewrite everything in a simulated way.
Myconstraints are that I am using a modular (acsx) architecture for pages, I have a RadWindowManager in the main page template(aspx) which loads dynamically modules. Each module need a way to confirm some buttn clicks.

If you could have first validated these options I have taken :
- using AjaxManager.ResponseScripts.Add(scrpt) in the page template on to install the alias for radconfirm in a way it always will appear after RadWindowManager declaration.
- using AjaxManager.ResponseScripts.Add(scrpt) on each call, callback or not (risk on aliasing multiple times ?), it seems that after an ajax callback generated by a control not using radconfirm, I loose the radConfirm handler ?
- should I include the radWindowManager as an updated control in RadAjaxManager ?

These small answer could help reducing 'my uncertain zone' directly without mounting a testbed.
Thanks for your time.

CS

0
Georgi Tunev
Telerik team
answered on 07 Nov 2008, 02:01 PM
Hi Christian,

I am not familiar with your exact setup, so I cannot provide definitive answers to your questions, but in general RadWindowManager does not need to be updated if you are using only its client-side API. Also AjaxManager.ResponseScripts.Add() method will add a script to the collection and because RadAjaxManager will be created at the same time as the RadWindowManager, the script should work fine.

This being said, I suggest to try isolating the several setups that you have in your real-life project in a separate application. Just make sure that your logic work fine with a standard window.confirm() function and send us the application (please make sure that it can be run locally and is not missing files or database). We will check it and rework it for you so it uses radconfirm() instead of window.confirm().



Kind regards,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
CSurieux
Top achievements
Rank 2
answered on 07 Nov 2008, 02:19 PM

Hello Georgi,

 

Again thanks for follow-up.

Do you know that thelink in emails you send are broken since new site? .... and the delete key is not working in this editor... 

 

I finally succeded in having a general script working, using RadAjax.ResponseScript just on the non callback.
I also found some interesting problem for IE (have to check for otjher browsers): I was using an anchor with an img inside so when I was clicking on the img, the anchor onclick event is triggered but the event. srcElement is the IMG ???? soI add to adapt the script for this case, taking the parentNode as callerObj.

 

It is uneasy to extract testbed from my application environment as it depends of an external application, without this application testing could be of no interest.

 

Thanks for help, hope that Telerik will do a move to have a special confirm objet in some futur.

 

CS

0
Georgi Tunev
Telerik team
answered on 07 Nov 2008, 02:59 PM
Yes, we are currently working on fixing the problem with the links - should be OK in a couple of hours.



Regards,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Window
Asked by
CSurieux
Top achievements
Rank 2
Answers by
Georgi Tunev
Telerik team
CSurieux
Top achievements
Rank 2
Share this question
or