Validation Summary from Modal Popup RRS feed

  • Question

  • User-962670764 posted

    I ave a modal popup that opoens wheni  user wants to log a ride.  The ride date cannot be in the future or more than 2 weeks past. I use a range validator for this. owever, when i click on the insert button it does not display the error in the validation summary. I have the DiIsplay property set to None and associated with the validation group. If Ichange it to Dynamic it is displayed correctly within the form, but not in the summary. I changed the validation to check if the Page is valid and Show the popup if it is not, but the error is not displayed.

    The HTML:

                            <table class="auto-style4">
                                    <td class="tdlt_50" colspan="5">
                                        <asp:ValidationSummary ID="vgrpadd" runat="server" ShowSummary="true" DisplayMode="BulletList" />
                                    <td class="tdlt_50">&nbsp;</td>
                                    <td class="tdrt_100">Date:</td>
                                    <td class="tdlt_100">
                                        <asp:TextBox ID="tbdate" runat="server" CssClass="tdlt_75"
                                            Text='<%# Bind("ridedate") %>' Width="65px" />
                                        <ajaxToolkit:CalendarExtender ID="TextBox2_CalendarExtender"
                                            runat="server" Enabled="True" PopupButtonID="imgcal" TargetControlID="tbdate" />
                                        &nbsp;<asp:ImageButton ID="imgcal" runat="server" ImageUrl="~/Images/Icons/calendar_1.png" />
                                        <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="tbdate"
                                            ErrorMessage="You cannot future date a ride or enter one more than 2 Months old" Display="None" ValidationGroup="vgrpadd" />

    The code:

     protected void InsertButton_Click(object sender, EventArgs e)
            if (!IsValid)
                RangeValidator Range = (RangeValidator)FormView1.FindControl("RangeValidator1");
                DateTime dtnowdt = DateTime.Today;
                TextBox tbrdate = (TextBox)FormView1.FindControl("tbdate");
                string dtnow = dtnowdt.ToShortDateString();
                //tbrdate.Text = dtnow;
                string dtmin = DateTime.Today.AddDays(-14).ToShortDateString();
                ValidationSummary vs = (ValidationSummary)FormView1.FindControl("vgrpadd");
                tbrdate.Text = dtnow;
                Range.MaximumValue = dtnow;
                Range.MinimumValue = dtmin;
                Range.Type = ValidationDataType.Date;
                Range.Display = ValidatorDisplay.None;
                Range.ValidationGroup = "vs";
                Range.ErrorMessage = "You cannot future date a ride or enter one more than 2 Weeks old";
               if (IsValid)

    Thursday, May 1, 2014 4:53 PM


  • User555306248 posted

    I think you will need to place a validation summary in the panel that is being shown in the popup,but you will need to give it and all the controls in the panel the same ValidationGroup:

    <asp:Panel ID="Panel1" runat="server">
            <asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="popupValidation" />
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
            <asp:TextBox ID="TextBox1" runat="server" ValidationGroup="popupValidation"></asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator"
            <asp:Button ID="Button1" runat="server" Text="Button" ValidationGroup="popupValidation" />


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, May 4, 2014 11:52 PM