Too much old samples for RadConfirm with RadWindow

6 posts, 0 answers
  1. CSurieux
    CSurieux avatar
    465 posts
    Member since:
    Jan 2007

    Posted 30 Oct 2008 Link to this post

    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
  2. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 04 Nov 2008 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. CSurieux
    CSurieux avatar
    465 posts
    Member since:
    Jan 2007

    Posted 04 Nov 2008 Link to this post

    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

  5. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 07 Nov 2008 Link to this post

    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.
  6. CSurieux
    CSurieux avatar
    465 posts
    Member since:
    Jan 2007

    Posted 07 Nov 2008 Link to this post

    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

  7. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 07 Nov 2008 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017