OnClientClicking & RequiredFieldValidator problems

2 posts, 1 answers
  1. Kurt Kluth
    Kurt Kluth avatar
    152 posts
    Member since:
    Oct 2009

    Posted 08 Oct 2014 Link to this post

    I have looked at the following forum post: http://www.telerik.com/forums/strange-behavior-when-using-args-set-cancel-true and although my code is similar still having odd behavior. 

    When clicking on the radButton it will fire the validation but it takes clicking on the "OK" button twice before the validation summary disappears.


    <telerik:RadCodeBlock runat="server">
        <script type="text/javascript">
            function ShowConfirm(clickedButton, args) {
                var validated = Page_ClientValidate('Form');
                if (validated) {
                    function callBackFunction(arg) {
                        if (arg == true) {
                    //Open the window
                    $find("<%=confirmWindow.ClientID %>").show();
                    //Focus the Yes button
                    $find("<%=btnYes.ClientID %>").focus();
                    //Cancel the postback
            function YesOrNoClicked(sender, args) {
                var oWnd = $find("<%=confirmWindow.ClientID %>");
                if (sender.get_text() == "Yes") {
                    $find("<%=_btnFinish.ClientID %>").click();

        <asp:Panel runat="server" ID="ShowHistorical" Visible="false">
            <td style="text-align: center;" align="center">There is no <strong>Historical data for <asp:Label ID="_Step2CUName" runat="server"></asp:Label>.</strong>  Please select this credit unions Member Type before proceeding.<br />
                <br />
                <telerik:RadDropDownList ID="_ddMember" runat="server" AutoPostBack="true" DefaultMessage="Select Member Type"></telerik:RadDropDownList>  
                <asp:RequiredFieldValidator ID="_reqValMemberType" runat="server" ControlToValidate="_ddMember" Text="*" ForeColor="Red"
                    ErrorMessage="You must select a Member Type before you can submit this Credit Union to be reinstated!<br />"
                    ValidationGroup="Form" Display="Dynamic" EnableClientScript="true"></asp:RequiredFieldValidator>
            <td align="center">
                <telerik:RadButton ID="_btnFinish" runat="server" Text="Finish" CommandName="Continue" ValidationGroup="Form"  Visible="false"
                <asp:ValidationSummary ID="ValidationSummary2" runat="server" ValidationGroup="Form" ShowMessageBox="true" ShowSummary="false"  DisplayMode="BulletList" />

    <telerik:RadWindowManager ID="windowManager1" runat="server">
    <telerik:RadWindow ID="confirmWindow" runat="server" VisibleTitlebar="false" VisibleStatusbar="false"
        Modal="true" Behaviors="None" Height="200px" Width="350px">
            <div style="margin-top: 30px; float: left;">
                    <div style="width: 60px; padding-left: 15px; float: left;">
                        <img src="/images/ModalDialogAlert.gif" alt="Confirm Page" />
                    <div style="width: 230px; float: left;">
                        <asp:Label ID="lblConfirm" Font-Size="14px" Text=""
                        <br />
                        <br />
                        <telerik:RadButton ID="btnYes" runat="server" Text="Yes" AutoPostBack="false" OnClientClicked="YesOrNoClicked">
                            <Icon PrimaryIconCssClass="rbOk"></Icon>
                        <telerik:RadButton ID="btnNo" runat="server" Text="No" AutoPostBack="false" OnClientClicked="YesOrNoClicked">
                            <Icon PrimaryIconCssClass="rbCancel"></Icon>

  2. Answer
    Danail Vasilev
    Danail Vasilev avatar
    1502 posts

    Posted 13 Oct 2014 Link to this post

    Hello Kurt,

    The Page_ClientValidate method validates the page once again when the button is clicked and that is why the validation summary popup shows twice. I can suggest that you place the logic that you want to be executed only when the validation passes and prior to the postback in the OnClientClicked event. The rest of the logic that you want to be executed every time the button is clicked can be placed in the OnClientClicking event.

    Danail Vasilev

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top