OnClientClicked Firing Before Validation?

2 posts, 0 answers
  1. Matt
    Matt avatar
    3 posts
    Member since:
    Oct 2012

    Posted 13 Mar 2013 Link to this post

    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) {
    <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" />
  2. Danail Vasilev
    Danail Vasilev avatar
    1502 posts

    Posted 15 Mar 2013 Link to this post

    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.
Back to Top