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

OnClientClicked Firing Before Validation?

1 Answer 196 Views
Button
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 13 Mar 2013, 06:28 PM
I have a radbutton that works with a validation group to check a drop down before showing a confirmation popup. I have found the OnClientClicked is firing before the validation is complete. I'm wondering if this could be related to the current issue with the radbutton and the Q1 2013 release. I am currently running last night's internal build.

<telerik:RadScriptBlock runat="server">
    <script type="text/javascript">
        function VALIDATEME(sender, args) {
            args.set_cancel(!window.confirm('Validate?'));
        }
    </script>
</telerik:RadScriptBlock>
 
<telerik:RadButton ID="SaveButton" runat="server" CausesValidation="true" CommandName="Save"
          Text="Save" OnClientClicked="VALIDATEME" ValidationGroup="Save" />
 
<telerik:RadComboBox ID="combo" runat="server" />
 
<asp:RequiredFieldValidator ID="validator" runat="server" ControlToValidate="combo" ValidationGroup="Save"
          InitialValue="" ErrorMessage="Error!" Text="*" />
 
<asp:ValidationSummary ID="ValidationSummary" runat="server" ValidationGroup="Save" />

1 Answer, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 15 Mar 2013, 11:16 AM
Hi Matt,

The client-side events - OnClientClicked and OnClientClicking are triggered after the execution of the validation, no matter whether the validation is successful or not. I have recorded a short video test here. This behavior is observed in the older versions of RadControls as well.

Note also that in your code snippet you are using OnClientClicked event which cannot be canceled because it is fired just before the page is submitted. OnClientClicking event, however, is triggered when the button is clicked, immediately after the mouse button is released and it can be canceled by set_cancel(true) method.

Kind regards,
Danail Vasilev
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.
Tags
Button
Asked by
Matt
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Share this question
or