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

OnClientClicking & RequiredFieldValidator problems

1 Answer 325 Views
Button
This is a migrated thread and some comments may be shown as answers.
Kurt Kluth
Top achievements
Rank 1
Kurt Kluth asked on 08 Oct 2014, 03:10 PM
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.

Suggestions?

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

    <asp:Panel runat="server" ID="ShowHistorical" Visible="false">
    <tr>
        <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>
    </tr>
    </asp:Panel>
    <tr>
        <td align="center">
            <telerik:RadButton ID="_btnFinish" runat="server" Text="Finish" CommandName="Continue" ValidationGroup="Form"  Visible="false"
                OnClientClicking="ShowConfirm"></telerik:RadButton>
            <asp:ValidationSummary ID="ValidationSummary2" runat="server" ValidationGroup="Form" ShowMessageBox="true" ShowSummary="false"  DisplayMode="BulletList" />
        </td>
    </tr>
</table>

<telerik:RadWindowManager ID="windowManager1" runat="server">
</telerik:RadWindowManager>
<telerik:RadWindow ID="confirmWindow" runat="server" VisibleTitlebar="false" VisibleStatusbar="false"
    Modal="true" Behaviors="None" Height="200px" Width="350px">
    <ContentTemplate>
        <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>
                <div style="width: 230px; float: left;">
                    <asp:Label ID="lblConfirm" Font-Size="14px" Text=""
                        runat="server"></asp:Label>
                    <br />
                    <br />
                    <telerik:RadButton ID="btnYes" runat="server" Text="Yes" AutoPostBack="false" OnClientClicked="YesOrNoClicked">
                        <Icon PrimaryIconCssClass="rbOk"></Icon>
                    </telerik:RadButton>
                    <telerik:RadButton ID="btnNo" runat="server" Text="No" AutoPostBack="false" OnClientClicked="YesOrNoClicked">
                        <Icon PrimaryIconCssClass="rbCancel"></Icon>
                    </telerik:RadButton>
                </div>
        </div>
    </ContentTemplate>
</telerik:RadWindow>







1 Answer, 1 is accepted

Sort by
0
Accepted
Danail Vasilev
Telerik team
answered on 13 Oct 2014, 11:10 AM
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.

Regards,
Danail Vasilev
Telerik
 

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.

 
Tags
Button
Asked by
Kurt Kluth
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Share this question
or