Block the execution thread with radconfirm

Thread is closed for posting
50 posts, 0 answers
  1. EFE25FBE-724F-4365-ACFD-08A8470E9CC7
    EFE25FBE-724F-4365-ACFD-08A8470E9CC7 avatar
    1337 posts
    Member since:
    Sep 2012

    Posted 25 Mar 2009 Link to this post

    Hello Greg,

    This problem has been reported a couple of times - indeed it does not occur regularly and it is difficult to duplicate. That said, we have changed the code so that the problem does not occur anymore. Hence, the reason for the problem would seem that you are using an older Telerik.Web.UI version. I suggest you try either the current Q1 2009 or (in case you are not able to upgrade to it for some reason) - the older Q3 2008 SP2.

    Best regards,
    Tervel
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  2. 60C5EDF8-67BD-43C4-882F-2910817EE324
    60C5EDF8-67BD-43C4-882F-2910817EE324 avatar
    3 posts
    Member since:
    Mar 2009

    Posted 25 Mar 2009 Link to this post

    Yes, I am indeed using Q2 2008. Will upgrade. Tnx.
  3. 089DAFBC-0A6F-4B74-9769-15D452B26106
    089DAFBC-0A6F-4B74-9769-15D452B26106 avatar
    20 posts
    Member since:
    May 2007

    Posted 29 Sep 2009 Link to this post

    I'm running into an issue when attempting to use a RadConfirm from inside a simple repeater.  I've used Xcalibur's technique with great success outside of a repeater.

    Its a simple LinkButton with an OnClick C# event.  As I'm binding the repeater I'm setting up the OnClientClick event for the button.

    Javascript:
    <script type="text/javascript"
    var btnName = ""
     
    function setButtonClientID(clientID, text, title)  
        btnName = clientID
        radconfirm(text, ClientCallback, 480, 180, '', title);  
         
    var ClientCallback = function (arg)   
        alert('btnName: ' + btnName + ' arg: ' + arg); 
     
        if (arg)  
        { 
            __doPostBack(document.getElementById(btnName), ''); 
        } 
    </script> 


    ASPX:
    <asp:LinkButton ID="btnRemove" runat="server" CommandArgument='<%#  Eval("ElementID") %>' CommandName="Remove" CssClass="button_100"
    <span class="cancel">Remove</span> 
    </asp:LinkButton> 


    C#:
    btnRemove.OnClientClick = "setButtonClientID('" + btnRemove.ClientID + "', 'Remove this Element?' , 'Confirm Remove?'); return false;"
     

    You'll notice in my Javascript that I'm using
    var ClientCallback = function (arg)   
    according to the "post-confirmation" logic stated in Reply #3

    The radconfirm comes up after pressing the btnRemove as expected along with the cancel button canceling the postback correctly. The alert that I call returns the expected variable strings, however when I press the 'OK' button I receive an error "Microsoft JScript runtime error: Object doesn't support this property or method" with "_uniqueIDToClientID:function(a){return a.replace(/\$/g,"_")}" highlighted in my Telerik.Web.UI.WebResource.axd

    Thanks in advance for any help!

    -Daniel
  4. 000585EE-7DFC-4C10-B6EB-448F2DA3AFB4
    000585EE-7DFC-4C10-B6EB-448F2DA3AFB4 avatar
    7207 posts
    Member since:
    Jul 2016

    Posted 30 Sep 2009 Link to this post

    Hello brewerdc,

    The code that you posted seems OK, so we will need to have a better view over your exact setup in order to help. Please open a support ticket and send us a small sample project where this issue could be reproduced - we will check it right away.


    Best wishes,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. 000585EE-7DFC-4C10-B6EB-448F2DA3AFB4
    000585EE-7DFC-4C10-B6EB-448F2DA3AFB4 avatar
    7207 posts
    Member since:
    Jul 2016

    Posted 02 Oct 2009 Link to this post

    Hello again Daniel,

    After receiving your project I noticed the problem in the code that I have missed in my previous reply - sorry about that.
    The _doPostBack() function accepts as a first parameter the ID of the element, not the object itself. If you change your code to
    __doPostBack(document.getElementById(btnName).id, '');
    it will work as expected.


    Best wishes,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. 0ED70244-46D7-415A-A4AA-DCA6801ADCDF
    0ED70244-46D7-415A-A4AA-DCA6801ADCDF avatar
    1 posts
    Member since:
    May 2009

    Posted 28 Oct 2009 Link to this post

    Hi Georgi,

    I am intercepting RadAjaxManager ClientEvents-OnRequestStart with the following ...

    function

    OnRequestStart(ajaxControl, eventArgs) {

     

     

        var eventTarget = eventArgs.EventTarget;

     

     

        var element = document.getElementById(eventTarget);

     

     

     

        var iframe = document.frames[iframeids[0]];

     

     

        var latestStepIndex = 0;

     

     

     

        
        if
    (typeof iframe != 'undefined')

     

            latestStepIndex = iframe.latestStepIndex;

     


        if
    (typeof latestStepIndex != 'undefined' && latestStepIndex > 0) {

     

     

            var complete = confirm('Are you sure?');

     

     

            if (!complete) {

     

     

                if (element.type == 'select-one') {

     

     

                    if (eventTarget != 'lstType')

     

                        element.selectedIndex = controlValues[eventTarget];

     

                    else

     

                        element.selectedIndex = -1;

                }

     

                else if (eventTarget == 'rblOriginator')

     

                    setRadioButtonListSelectedIndex(element, controlValues[eventTarget]);

             }

     

                
            return
    complete;

     

        }

     

        else {

     

     

            if (element.type == 'select-one')

     

                controlValues[eventTarget] = element.selectedIndex;

     

            else if (eventTarget == 'rblOriginator')

     

                controlValues[eventTarget] = getRadioButtonListSelectedIndex(element);

     

     

            return true;

     

        }

    }

    The page with ajax manager has a menu which then loads a different page (living in a different application) into an iframe. If the user is so far through the wizard in the iframe and then clicks a menu option. Menu selection fires of ajax call (and method above) and I ask the user if they are sure they want to reload page in iframe. If not sure then I cancel request and reinstate the menu control previous value. This works like a dream using the standard confirm box. Is it possible to use the RadConfirm in this scenario and if so how would this be done?

    Thanks
    John

  7. 000585EE-7DFC-4C10-B6EB-448F2DA3AFB4
    000585EE-7DFC-4C10-B6EB-448F2DA3AFB4 avatar
    7207 posts
    Member since:
    Jul 2016

    Posted 28 Oct 2009 Link to this post

    Hello John,

    I'm afraid this is not possible. As noted in this code library, radconfirm, radalert and radprompt cannot block the execution thread like the standard popups. The solution that is provided here mimic such behavior, but it cannot be applied to your case.


    Regards,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  8. A8E9FC04-D131-4F1E-9FBB-BBFB49EC100C
    A8E9FC04-D131-4F1E-9FBB-BBFB49EC100C avatar
    3 posts
    Member since:
    Apr 2010

    Posted 26 May 2010 Link to this post

    I'm using this code with success to catch if a page is dirty before navigating away and displaying the radconfirm instead of the default IE javascript confirmation dialog.

    My question is, we're using a  ConfirmDialogType="RadWindow" on a Telerik GridButtonColumn, which seems to map to the radconfirm call. Throughout other places in our app, I had to change all previous references from radcofirm to "oldRadConfirm" (as demonstarted in the example).

    Is there anyway to map the RadWindow in ConfirmDialogType to oldRadConfirm, so this works?

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

    Posted 28 May 2010 Link to this post

    Hi David,

    If you use RadControls for ASP.NET AJAX, then I recommend you to use this simple approach in order to  block the execution thread with radconfirm.

    I hope this helps.

    All the best,
    Fiko
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  10. C722EFC1-7E58-4254-8B7C-49AB04B2CF77
    C722EFC1-7E58-4254-8B7C-49AB04B2CF77 avatar
    47 posts
    Member since:
    Sep 2005

    Posted 18 Jun 2010 Link to this post

    Hello,

    My environment is VS 2010 with Telerik Telerik.Web.UI version 2009.3.1314.35.

    I managed to reproduce the beahviour has expeted in IE, ie, I have a remove button, when I press the button I get the confirmation window.

    But in FF 3.6.3 the behaviour is somewhat unexepected: when I press the button I get the confirmation window but if I press "OK" nothing happens, but when I press a second time than the browser doesn't show any confirm message and immediately execute the code-behind code. Thus the steps in FF are: 1) Press button remove; 2) Press OK in the radalert window; 3) Press button remove again; 4) Browser executes automatically the code-behind.


    Here is the code:

    <telerik:radwindowmanager id="radInfoWindow" runat="server" > 
                 
                </telerik:radwindowmanager> 
                 
                <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">   
                    <script type="text/javascript"
     
                        //MAKE SURE THAT THE FOLLOWING SCRIPT IS PLACED AFTER THE RADWINDOWMANAGER DECLARATION 
                        //Replace old radconfirm with a changed version.    
                        var oldConfirm = radconfirm; 
                        //TELERIK 
                        //window.radconfirm = function(text, mozEvent) 
                        //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) { } 
                                        } 
                                    } 
                                } 
                                //TELERIK 
                                //oldConfirm(text, callBackFn, 300, 100, null, null);        
                                //We will need to modify the oldconfirm as well                 
                                oldConfirm(text, callBackFn, oWidth, oHeight, callerObj, oTitle); 
                            } 
                            return false
                        }   
                            </script> 
     
         </telerik:RadCodeBlock>   


     <asp:LinkButton ID="lkbRemove" runat="server" onclick="lkbRemove_Click" onclientclick="return radconfirm('Are you sure?', event, 330, 100, '','Sure?'); ">remove</asp:LinkButton> 


  11. 000585EE-7DFC-4C10-B6EB-448F2DA3AFB4
    000585EE-7DFC-4C10-B6EB-448F2DA3AFB4 avatar
    7207 posts
    Member since:
    Jul 2016

    Posted 22 Jun 2010 Link to this post

    Hi Regula,

    As noted in all articles that reference the workaround that you are using, this code is considered a hack and we do not guarantee that it will work in all cases.
    What I can suggest in your case, is to use RadAjaxManager and its ajaxRequestWithTarget() function - please find attached a small sample that shows how to achieve the desired result.


    Best wishes,
    Georgi Tunev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  12. BE2748BB-AE58-4ECD-86B9-5A906B93C0FB
    BE2748BB-AE58-4ECD-86B9-5A906B93C0FB avatar
    10 posts
    Member since:
    Apr 2010

    Posted 15 Nov 2010 Link to this post

    Hi All,

    has this "blocking" behaviour been implemented yet as a standard feature in the radconfirm method ?

    or do we still have to use the "workaround" as provided in this thread ?
  13. 000585EE-7DFC-4C10-B6EB-448F2DA3AFB4
    000585EE-7DFC-4C10-B6EB-448F2DA3AFB4 avatar
    7207 posts
    Member since:
    Jul 2016

    Posted 16 Nov 2010 Link to this post

    Hello Dr. Evil,

    There is no "ultimate" solution that would produce consistent result in all browsers and in all scenarios, like the standard confirm popup. That is why the approach, described here, hasn't been implemented in radconfirm - as noted before, the approach is considered a hack and it works in certain scenarios only.


    All the best,
    Georgi Tunev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  14. BD1DCEF2-517A-4815-A4ED-4838B818DCF2
    BD1DCEF2-517A-4815-A4ED-4838B818DCF2 avatar
    1 posts
    Member since:
    Apr 2010

    Posted 23 Dec 2010 Link to this post

    Hello,

    I took this callback blocking exec solution and implemented into a project.  But I work when the page is "ajaxified".

    I have the following ajaxsetting in my radajaxmanager:

            <telerik:AjaxSetting AjaxControlID="btnUpdate">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="btnUpdate" />
                    <telerik:AjaxUpdatedControl ControlID="ResponseControl1" />
                </UpdatedControls>
            </telerik:AjaxSetting>

    ResponseControl1 is a custom control on our side.  

    Here is what btnUpdate looks like:

                <asp:Button ID="btnUpdate" Text="Submit" runat="server"  OnClientClick="return blockConfirm('Are you sure you want to submit?', event, 250, 100,'','Submit?');"
                    Visible="false" CommandName="Update" SkinID="MPPSkin" OnClick="btnUpdate_Click" />

    Note the visible="false" is set back to true on page_init.  When I tried to execute the button click, I get the confirmation window.  But when I click yes in the confirm window, the code behind of the button click doesn't get executed.  But if I remove the ajaxsetting for btnUpdate, everything executes.

    How can I make this code "ajaxified"?

    thanks,
    Luis

    BTW - i'm using the blocking execution code that is posted on the telerik demo website for radwindow:
    http://demos.telerik.com/aspnet-ajax/window/examples/browserdialogboxes/defaultcs.aspx
  15. 93662917-1E03-49EC-9286-033C9D1BF79E
    93662917-1E03-49EC-9286-033C9D1BF79E avatar
    1406 posts
    Member since:
    May 2014

    Posted 27 Dec 2010 Link to this post

    Hello Luis,

    I recommend you to use this very simple approach in order to achieve the desired result:

    ASPX:
    <head id="Head1" runat="server">
        <title></title>
        <script type="text/javascript">
            function blockConfirm(clickedButton)
            {
                function confirmHandler(args)
                {
                    if (args == true)
                    {
                        __doPostBack(clickedButton.name, "");
                    }
                }
                radconfirm('Are you sure you want to submit?', confirmHandler, 250, 100, null, 'Submit?')
     
                return false;
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="Scriptmanager1" runat="server">
        </asp:ScriptManager>
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
        </telerik:RadWindowManager>
        <telerik:RadAjaxManager IS="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="btnUpdate">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="btnUpdate" />
                        <telerik:AjaxUpdatedControl ControlID="ResponseControl1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <asp:Button ID="btnUpdate" Text="Submit" runat="server" OnClientClick="return blockConfirm(this);"
            Visible="false" CommandName="Update" SkinID="MPPSkin" OnClick="btnUpdate_Click" />
        <asp:Label ID="ResponseControl1" runat="server"></asp:Label>
        </form>
    </body>
    </html>


    Codebehind:
    protected void Page_Init(object sender, EventArgs e)
    {
        btnUpdate.Visible = true;
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        ResponseControl1.Text = DateTime.Now.ToString();
    }

    I hope this helps.

    Best wishes,
    Fiko
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  16. 151BAEF6-A9A7-4F6A-9BB8-6B79D315669D
    151BAEF6-A9A7-4F6A-9BB8-6B79D315669D avatar
    22 posts
    Member since:
    Apr 2008

    Posted 28 Jun 2011 Link to this post

    Hi there,

    I use the code snipped which was here provided to block the excecution within the RadConfrim.

    But it seems that this is not longer working with firefox 5.
    Can you confirm this?
    On FF5 just nothing happens - no javascript error or something like this.

    Thank you!
    Felix
  17. A1CE16C4-4C2E-464E-BF18-532525D276CA
    A1CE16C4-4C2E-464E-BF18-532525D276CA avatar
    5948 posts
    Member since:
    Apr 2022

    Posted 28 Jun 2011 Link to this post

    Hello Felix,

    The original post and code have been prepared for older versions of the .NET framework and the RadControls for ASP. As noted in previous replies this approach is generally considered to be a hack and it is not guaranteed that it will work in all cases.

    Please try using the newer version which only uses a callback function instead of overriding the entire radconfirm() method.

    That being said the following code seems to work fine under FF5 as well:
    <asp:Button ID="Button1" Text="text" runat="server" OnClientClick="return blockConfirm(this);" OnClick="Button1_Click" />

    function blockConfirm(clickedButton)
    {
        function confirmHandler(args)
        {
            if (args == true)
            {
                __doPostBack(clickedButton.name, "");
            }
        }
        radconfirm('Are you sure you want to submit?', confirmHandler, 250, 100, null, 'Submit?')
     
        return false;
    }

    Please note that in the case of a link button you would need to pass its id and not its name to the __doPostBack() function.

    All the best,
    Marin
    the Telerik team

    Consider using RadControls for ASP.NET AJAX (built on top of the ASP.NET AJAX framework) as a replacement for the Telerik ASP.NET Classic controls, See the product support lifecycle here.

  18. 151BAEF6-A9A7-4F6A-9BB8-6B79D315669D
    151BAEF6-A9A7-4F6A-9BB8-6B79D315669D avatar
    22 posts
    Member since:
    Apr 2008

    Posted 28 Jun 2011 Link to this post

    Hi Marin,

    thank you for your quick response.

    The solution you provided looks fine but we implemented about 50 radconfirm-calls in our software.
    So this is a whole bunch of time we had to spend on re-implementing this.

    Is there any other soloution?
    Or could you tell us if there is a fault on mozillas side causing this problem or is this a problem on your side?
    If found this bug according to FF5 (https://bugzilla.mozilla.org/show_bug.cgi?id=666955) and Telerik Ajax.
    Could this have something to to with our problem?

    Thanks again,
    Felix
  19. A1CE16C4-4C2E-464E-BF18-532525D276CA
    A1CE16C4-4C2E-464E-BF18-532525D276CA avatar
    5948 posts
    Member since:
    Apr 2022

    Posted 29 Jun 2011 Link to this post

    Hello Felix,

      This code has been created years ago for the RadControls for ASP suite, which is not designed to work with AJAX. Therefore when AJAX is introduced you will experience some unexpected behavior with it - namely - it does not work when the initiators perform an AJAX request and not a postback.

    What I would advise is that you do not use this hack, but move to using the callback function as shown in the later posts.

    That being said - I cannot confirm if this issue with FF5 is related to this case, but it seems that the guys from Mozilla are changing the behavior related to the client-side click() method for links and it is yet to be seen and tested what will come of it.


    Greetings,
    Marin
    the Telerik team

    Consider using RadControls for ASP.NET AJAX (built on top of the ASP.NET AJAX framework) as a replacement for the Telerik ASP.NET Classic controls, See the product support lifecycle here.

  20. 54304044-7CE8-4777-9C9F-0B54AA67E5BA
    54304044-7CE8-4777-9C9F-0B54AA67E5BA avatar
    13 posts
    Member since:
    Dec 2008

    Posted 04 Aug 2011 Link to this post

    try this:
    var originalRadConfirm = radconfirm;
    window.radconfirm = function(text, mozEvent, oWidth, oHeight, callerObj, oTitle) {
        var ev = mozEvent ? mozEvent : window.event; 
        ev.cancelBubble = true;
        ev.returnValue = false;
        if (ev.stopPropagation) ev.stopPropagation();
        if (ev.preventDefault) ev.preventDefault();
      
        var callerObj = ev.srcElement ? ev.srcElement : ev.target;
      
        if (callerObj) {
            var callBackFn = function(arg) {
                if (arg) {
                    callerObj["onclick"] = "";
                    var isFF = false;
                    if (window.$telerik && window.$telerik.isFirefox) {
                        isFF = true;
                    }
                    if (callerObj.click && !isFF) {
                        callerObj.click();                
                    }
                    else if (callerObj.tagName == "A")   
                    {
                        try {
                            eval(callerObj.href)
                        }
                        catch (e) { }
                    }
                }
            }
            originalRadConfirm(text, callBackFn, oWidth, oHeight, callerObj, oTitle);
        }
        return false;
    }
Back to Top

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