RadButton .click() Isn't calling OnClientClicking

6 posts, 0 answers
  1. Fergal
    Fergal avatar
    23 posts
    Member since:
    Jun 2012

    Posted 26 Nov 2012 Link to this post

    Hi.

    I have a radbutton that is hooked up with the OnClientClicking event to a Javascript function. Inside this function, I'm calling radConfirm, and passing it a callback function. Within this callback function, I am evaluating the response, and then calling the .click() method in order to restart the process.

    I'm expecting the .click() method to re-call the OnClientClicking event (which has logic to handle the fact that it's being called again and, if necessary suppress the radconfirm). However, it doesn't appear like this is happening.

    Am I doing something wrong?

    <telerik:RadButton runat="server" ID="btnTest" OnClientClicking="clicking" />
    var LastClickedItem = null;
    var clickCalledfromConfirm = false;
     
    function clicking(sender, args)
    {
        if (!clickCalledfromConfirm)
        {
            args.set_cancel(true);
            LastClickedItem = sender;
            radconfirm("Are you sure you want to do this?", confirmCallBack);
        }
        else
        {
            args.set_cancel(false);
        }
    }
     
    function confirmCallBack(args)
    {
        if (args)
        {
            clickCalledFromConfirm = true;
            LastClickedItem.click();
        }
    }

    Thanks
    Fergal
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 26 Nov 2012 Link to this post

    Hi Fregal,

    The .click(); function executes programmatic button click. I have made some modifications in your code to call the OnClientClicking event.
    JS:
    <script type="text/javascript">
      var LastClickedItem = null;
        var clickCalledfromConfirm = false;
        var argnew;
        function clicking(sender,args) {
           argnew = args;
            if (!clickCalledfromConfirm) {
                args.set_cancel(true);
                LastClickedItem = sender;
                radconfirm("Are you sure you want to do this?", confirmCallBack);
            }
            else {
                args.set_cancel(false);
            }
        }
     function confirmCallBack(args) {
            if (args) {
      clickCalledFromConfirm = true;
     clicking(LastClickedItem, argnew);
            }
        }
    </script>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Fergal
    Fergal avatar
    23 posts
    Member since:
    Jun 2012

    Posted 27 Nov 2012 Link to this post

    Thanks Princy, that was pretty much how I was getting around it here. I was just hoping that there was a neater method of doing it. Particularly when the functionality is inconsistent with a Menu Item click (which does call the clicking event).
  5. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 29 Nov 2012 Link to this post

    Hi Fergal,

    The client-side click method of RadButton accepts a Boolean parameter that specifies whether the clicking event will be fired. If you call it as shown below, your handler function clicking will be executed:
    LastClickedItem.click(true);

    The client-side API help article of RadButton will be updated accordingly, since currently it does not clarify what parameters should be passed to the click function.

    Kind regards,
    Slav
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  6. MTC
    MTC avatar
    26 posts
    Member since:
    Jan 2013

    Posted 13 Feb 2013 Link to this post

    Hi
    I have a simple requirement to create a record in Data Base. for this i have some fields on my webpage after filling that fields user can create a record.
    for this i am using RadAjaxPanel,RadScriptBlock,Rad Button,RadAjaxManager and RadAjaxLoadingPanel.
    the flow for creating r record would be:
    -> On button click first i want to call a JavaScript for validation( not asp validation) it returns true for successful validation else false..
    ->if it is true loading panel should appear on the screen and server side code should run.
    -> if it is false then loading panel should not appear JavaScript error message should display..

    Please help....
  7. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 14 Feb 2013 Link to this post

    Hello Shweta,

    I have provided information about your scenario in this forum, which you used for reporting the same problem. Please follow the listed steps for implementing the desired functionality.

    I would suggest using a single forum thread when reporting a problem in the future. This way all the information on the case will be in one place which will allow us to resolve the issue faster. Let us continue our discussion in the thread I linked above.

    Greetings,
    Slav
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017