Validating fields in a FormTemplate

6 posts, 0 answers
  1. Michael
    Michael avatar
    38 posts
    Member since:
    Mar 2009

    Posted 04 Aug Link to this post

    I can't seem to trigger my validators within my FormTemplate on my grid. I can't find any examples of this either. Is it possible? Do I have to resort to using client side JS to manually trigger them on the submit?

     

    <ValidationSettings EnableValidation="true" CommandsToValidate="PerformInsert,Update" />

    <FormTemplate>
                                        <table>
                                            <tr>
                                                <td>Milestone Name: </td>
                                                <td>
                                                    <asp:TextBox runat="server" Text='<%# Bind("Name") %>' ID="txtMilestoneName" />
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="txtMilestoneName" 
                                                        runat="server" ErrorMessage="* - Required Field"  Display="Dynamic" ValidationGroup="Milestone"
                                                        ForeColor="Red" Font-Bold="true"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>Pipline: </td>
                                                <td><asp:DropDownList runat="server" SelectedValue='<%# Bind("PipelineID") %>' ID="ddlPipline"
                                                    ItemType="ONEOK.BusinessData.BusinessObjects.Pipeline"
                                                DataTextField="Name" DataValueField="PipelineID" SelectMethod="getPipelines" AppendDataBoundItems="true">
                                                    <asp:ListItem Text="Select..." Value="0" />
                                                </asp:DropDownList>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="ddlPipline"
                                                        ErrorMessage="* - Required Field" InitialValue="" ForeColor="Red" Font-Bold="true"></asp:RequiredFieldValidator>

                                                </td>
                                            </tr>
                                            <tr>
                                                <td>Threshold Value: </td>
                                                <td>
                                                    <asp:TextBox runat="server" Text='<%# Bind("MilestoneThresholdValue") %>' ID="txtMilestoneThresholdValue" />
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="txtMilestoneThresholdValue" runat="server" ErrorMessage="* - Required Field" ForeColor="Red" Font-Bold="true"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>Latitude: </td>
                                                <td>
                                                    <asp:TextBox runat="server" Text='<%# Bind("Latitude") %>' ID="txtLatitude" />
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" ControlToValidate="txtLatitude" runat="server" ErrorMessage="* - Required Field" ForeColor="Red" Font-Bold="true"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>Longitude: </td>
                                                <td>
                                                    <asp:TextBox runat="server" Text='<%# Bind("Longitude") %>' ID="txtLongitude" />
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator6" ControlToValidate="txtLongitude" runat="server" ErrorMessage="* - Required Field" ForeColor="Red" Font-Bold="true"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td valign="top">Photo: </td>
                                                <td>
                                                    <telerik:RadBinaryImage ID="rbiMilestone" DataValue='<%# Eval("Photo") %>' runat="server" />
                                                    <telerik:RadAsyncUpload ID="radMilestoneImage" AllowedFileExtensions="jpg,jpeg,png,gif" runat="server" 
                                                         
                                                        AutoAddFileInputs="false" Localization-Select="Upload Image"></telerik:RadAsyncUpload>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>Milestone Information: </td>
                                                <td><telerik:RadEditor ID="radEventLongDesc" Content='<%# Bind("MilestoneInformation") %>' ContentAreaCssFile="~/content/rte.css" runat="server" Width="500px" ToolbarMode="PageTop" BackColor="White"></telerik:RadEditor></td>
                                            </tr>
                                            <tr>
                                                <td align="center" colspan="2">
                                                    <asp:Button ID="btnUpdate" CausesValidation="true" ValidationGroup="Milestone" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                                        runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'></asp:Button>&nbsp;
                                                    <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                                        CommandName="Cancel"></asp:Button>
                                                </td>
                                            </tr>
                                        </table>
                                    </FormTemplate>

  2. Eyup
    Admin
    Eyup avatar
    3013 posts

    Posted 09 Aug Link to this post

    Hi Michael,

    Try removing the ValidationGroup property from the Button and everything should be fine.
    I am also sending a sample web site sample with similar implementation as a reference.

    Regards,
    Eyup
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Michael
    Michael avatar
    38 posts
    Member since:
    Mar 2009

    Posted 09 Aug in reply to Eyup Link to this post

    There are several different validation groups on this page. Won't they all be submitted with any submit button if I do that?
  5. Eyup
    Admin
    Eyup avatar
    3013 posts

    Posted 12 Aug Link to this post

    Hello Michael,

    Yes, you are correct. If you want to prevent that, you should set ValidationGroup for the entire edit form controls, including the validation ones, similar to the attached web site sample.

    Regards,
    Eyup
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  6. Michael
    Michael avatar
    38 posts
    Member since:
    Mar 2009

    Posted 12 Aug in reply to Eyup Link to this post

    So if I'm using a wizard and a form in each step, with the formtemplates in grids within each step, validation for those isn't going to work?
  7. Eyup
    Admin
    Eyup avatar
    3013 posts

    Posted 17 Aug Link to this post

    Hi Michael,

    If the buttons of the wizard aren't of type submit or if their ValidationGroup is not the same as the form elements, it is expected for the validation not to fire.

    Regards,
    Eyup
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017