radbutton not validate required field validator after click event

2 posts, 0 answers
  1. Dhamodharan
    Dhamodharan avatar
    300 posts
    Member since:
    Sep 2010

    Posted 05 Oct 2011 Link to this post

    Hi,

    I have three table in my page. first table have radbutton for save with radtextbox using required field validator. first time error message displayed. i am using ajax loading panel for the particular table. first time record saved successfully with loading panel. but second time required field validator not firing. click event firing with empty radtextbox.

    How to fix this problem. i have attached code. please check and let me know.

      <telerik:AjaxSetting AjaxControlID="rbSave">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="tblAttachFiles"  LoadingPanelID="ralpAttachment"  />              
                    </UpdatedControls>
                </telerik:AjaxSetting>


       <asp:Table ID="tblSaveAttachment" runat="server" border="2" Style="font-family: Segoe UI;
                                            font-size: 12px; font-weight: bold" Width="600px">
                                            <asp:TableRow>
                                                <asp:TableCell ID="tblAttachSaveFirst" Width="100px" runat="server" Text="FileName: "></asp:TableCell>
                                                <asp:TableCell>
                                                    <asp:Label ID="lblFileName" runat="server"></asp:Label>
                                                    <asp:HiddenField ID="hfFileName" runat="server" />
                                                </asp:TableCell>
                                            </asp:TableRow>
                                            <asp:TableRow>
                                                <asp:TableCell ID="tcSSN_GrpNum_Tin" runat="server" Text="SSN: "></asp:TableCell>
                                                <asp:TableCell>
                                                    <asp:HiddenField ID="hf_Pty_payinfo_id" runat="server" />
                                                    <telerik:RadTextBox ID="txtSSN_GrpNum_Tin" runat="server" onblur="ssn_onBlur()" Width="191px">
                                                    </telerik:RadTextBox>
                                                    <asp:Label ID="lblSSN_GrpNum_Tin" runat="server" style="display:none;visibility:hidden"></asp:Label>
                                                    <asp:Label ID="lblMantxtSSN_GrpNum_Tin" runat="server" Text=" * "
                                                        ForeColor="Red"></asp:Label>
                                                    <asp:RequiredFieldValidator ID="rfvtxtSSN_GrpNum_Tin" runat="server" ControlToValidate="txtSSN_GrpNum_Tin"
                                                        Display="Static" ForeColor="Red" Font-Bold="false" ValidationGroup="Validate"
                                                        Text="Please enter SSN"></asp:RequiredFieldValidator>
                                                </asp:TableCell>
                                            </asp:TableRow>
                                            <asp:TableRow>
                                                <asp:TableCell ID="tcCliam_Group_SSN_Provider_Name" runat="server" Text="Name:">
                <%--<asp:Label ID="lblCliam_Group_SSN_Provider_Name" runat="server" Text="Name:"></asp:Label>--%>
                                                </asp:TableCell><asp:TableCell>
                                                    <telerik:RadComboBox ID="rcbCliam_Group_SSN_Provider_Name" runat="server" Width="195px"
                                                        AutoPostBack="false" OnClientSelectedIndexChanged="rcbCliam_Group_SSN_Provider_Name_OnClientSelectedIndexChanged">
                                                        <Items>
                                                            <telerik:RadComboBoxItem Text="" Value="" />
                                                        </Items>
                                                    </telerik:RadComboBox>
                                                    <label id="lblCliam_Group_SSN_Provider_Name" runat="server" style="display:none;visibility:hidden"></label>
                                                    <asp:Label ID="lblManCliam_Group_SSN_Provider_Name" runat="server" Text=" * " ForeColor="Red"></asp:Label>
                                                    <asp:RequiredFieldValidator ID="rfvCliam_Group_SSN_Provider_Name" runat="server"
                                                        ControlToValidate="rcbCliam_Group_SSN_Provider_Name" Display="Static" ForeColor="Red"
                                                        Font-Bold="false" InitialValue="" ValidationGroup="Validate" Text="Please select Name"></asp:RequiredFieldValidator>
                                                </asp:TableCell></asp:TableRow>
                                            <asp:TableRow>
                                                <asp:TableCell ID="tclDocType" runat="server" Text="Document Type:">
              <%--  <asp:Label ID="lblDocType" runat="server" Text="Document Type:"></asp:Label>--%>
                                                </asp:TableCell><asp:TableCell>
                                                    <telerik:RadComboBox ID="rcbDocType" runat="server" Width="195px">
                                                        <Items>
                                                            <telerik:RadComboBoxItem Text="" Value="" />
                                                        </Items>
                                                    </telerik:RadComboBox>
                                                    <label id="lblDocType" runat="server" style="display:none;visibility:hidden"></label>
                                                    <asp:Label ID="lblManDocType" runat="server" Text=" * " ForeColor="Red"></asp:Label>
                                                    <asp:RequiredFieldValidator ID="rfvDocType" runat="server" ControlToValidate="rcbDocType"
                                                        Display="Static" ForeColor="Red" Font-Bold="false" InitialValue=""
                                                        ValidationGroup="Validate" Text="Please select Document Type"></asp:RequiredFieldValidator>
                                                </asp:TableCell></asp:TableRow>
                                            <asp:TableRow ID="trCliamId" runat="server">
                                                <asp:TableCell ID="tcCliamId" runat="server" Text="Cliam Id:">
                 <%--<asp:Label ID="lblCliamId_PlanTypes" runat="server" Text="Cliam Id:"></asp:Label>--%>
                                                </asp:TableCell><asp:TableCell>
                                                    <telerik:RadTextBox ID="txtCliamId" runat="server" onblur="CliamId_onBlur()" Width="191px">
                                                    </telerik:RadTextBox>
                                                    <asp:Label ID="lblCliamId" runat="server" style="display:none;visibility:hidden"></asp:Label>
                                                    <asp:Label ID="lblManCliamId" runat="server" Text=" * " ForeColor="Red"></asp:Label>
                                                    <asp:RequiredFieldValidator ID="rfvCliamId" runat="server" ControlToValidate="txtCliamId"
                                                        Enabled="false" Display="Static" ForeColor="Red" Font-Bold="false" ValidationGroup="Validate"
                                                        Text="Please enter Cliam Id"></asp:RequiredFieldValidator>
                                                </asp:TableCell></asp:TableRow>
                                            <asp:TableRow ID="trPlanType" runat="server">
                                                <asp:TableCell ID="tcPlanType" runat="server" Text="Plan Type:">
                 <%--<asp:Label ID="lblCliamId_PlanTypes" runat="server" Text="Cliam Id:"></asp:Label>--%>
                                                </asp:TableCell><asp:TableCell>
                                                    <telerik:RadComboBox ID="rcPlanType" runat="server" Width="195px">
                                                        <Items>
                                                            <telerik:RadComboBoxItem Text="" Value="" />
                                                        </Items>
                                                    </telerik:RadComboBox>
                                                     <asp:Label ID="lblPlanType" runat="server" style="display:none;visibility:hidden"></asp:Label>
                                                    <asp:Label ID="lblManPlanType" runat="server" Text=" * " ForeColor="Red"></asp:Label>
                                                    <asp:RequiredFieldValidator ID="rfvPlanType" runat="server" ControlToValidate="rcPlanType"
                                                        Display="Static" ForeColor="Red" Font-Bold="false" InitialValue="" ValidationGroup="Validate"
                                                        Text="Please Select Plan Type"></asp:RequiredFieldValidator>
                                                </asp:TableCell></asp:TableRow>
                                            <asp:TableRow>
                                                <asp:TableCell>
                                                    <asp:Label ID="lblDesc" runat="server" Text="Discription:"></asp:Label>
                                                </asp:TableCell><asp:TableCell>
                                                    <telerik:RadTextBox ID="txt_Discription" runat="server" Width="250px" ClientEvents-OnKeyPress="txtSaveBtn_OnKeyPress">
                                                    </telerik:RadTextBox>
                                                     <asp:Label ID="lblDiscription" runat="server" style="display:none;visibility:hidden"></asp:Label>
                                                    <asp:Label ID="lblManDesc" runat="server" Text=" * " ForeColor="Red"></asp:Label>
                                                    <asp:RequiredFieldValidator ID="rfvDescrip" runat="server" ControlToValidate="txt_Discription"
                                                        Display="Static" ForeColor="Red" Font-Bold="false" ValidationGroup="Validate"
                                                        Text="Please enter Description"></asp:RequiredFieldValidator>
                                                </asp:TableCell></asp:TableRow>
                                            <asp:TableRow ID="trBtn" runat="server">
                                                <asp:TableCell ColumnSpan="2" HorizontalAlign="Center">
                                                    <telerik:RadButton ID="rbSave" runat="server" Text="Save" Width="75px" OnClientClicked="rbSave_OnClientClicked"
                                                        ValidationGroup="Validate" CausesValidation="false" UseSubmitBehavior="false">
                                                    </telerik:RadButton>
                                                    &nbsp;&nbsp;
                                                    <telerik:RadButton ID="rbCancel" runat="server" Text="Cancel" Width="75px" OnClientClicked="rbCancel_OnClientClicked">
                                                    </telerik:RadButton>
                                                </asp:TableCell></asp:TableRow>
                                        </asp:Table>


    Thanks,
    Dhamu
  2. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 07 Oct 2011 Link to this post

    Hi Dhamodharan,

    Could you please verify that the provided code sample is from your actual project? The RadButton with ID set to rbSave, which you are probably using for saving the data, has property CausesValidation configured with value false. This will exclude the particular button control from the validation mechanism of your page and as a result the RadButton will never initiate validation when clicked, so you should set its property CausesValidation to true.

    I noticed that you have attached a client-side event handler for the save RadButton, which is not included into the code snippet. This event handler may be interfering with the validation of the page. If this is the case, you should check whether the page is validated on the client, before executing the main logic of the handler method, as demonstrated in this help article.

    Note that at the current state of affairs I am mostly guessing as to what your setup is. If you are still experiencing difficulties please prepare and send us a sample, runnable project that displays your issue so that we can examine it locally and provide a more to the point answer.

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top