This is a migrated thread and some comments may be shown as answers.
RadButton .click() Isn't calling OnClientClicking
5 Answers 183 Views
This is a migrated thread and some comments may be shown as answers.
Fergal
Top achievements
Rank 1
Fergal asked on 26 Nov 2012, 01:47 PM
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

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 27 Nov 2012, 05:31 AM
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.
0
Fergal
Top achievements
Rank 1
answered on 27 Nov 2012, 09:36 AM
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).
0
Slav
Telerik team
answered on 29 Nov 2012, 11:25 AM
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.
0
MTC
Top achievements
Rank 1
answered on 13 Feb 2013, 07:24 AM
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....
0
Slav
Telerik team
answered on 14 Feb 2013, 05:56 PM
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.
Asked by
Fergal
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Fergal
Top achievements
Rank 1
Slav
Telerik team
MTC
Top achievements
Rank 1
Share this question
or