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:
<InsertItemTemplate><table class="auto-style4"><tr><td class="tdlt_50" colspan="5"><asp:ValidationSummary ID="vgrpadd" runat="server" ShowSummary="true" DisplayMode="BulletList" /></td><td> </td></tr><tr><td class="tdlt_50"> </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" /> <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" /></td>
The code:
protected void InsertButton_Click(object sender, EventArgs e) { Page.Validate(); 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"; mpe_detail.Show(); } if (IsValid) { mpe_detail.Hide(); } }