.aspx page does not load after adding Validators in VB.Net

136 Views Asked by At

I have an aspx page with a few FormViews and an updateable GridView that I would like to add validation for. The fields that I am trying to validate are also using the CalendarExtender from the AJAX Control Toolkit by the way. I am trying to use the RequiredFieldValidator and RangeValidator for this. The problem is I don't see any errors from within VisualStudio 2015 while adding the validators. But when I run debug mode and click the button to open a FormView that contains validation I get a 500 error without any useful information to find/fix my problem.

I first tried adding both of the validators at once but after having problems, I am just trying to get the RequiredFiledValidator working. But I still need to know how to get the RangeValidator to work properly. For the RangeValidator, I want to validate a start date of no less than today and an end date that is greater than the start date. I tried using all of the examples that I found on these pages:

[1] https://www.c-sharpcorner.com/UploadFile/17e8f6/requiredfieldvalidator-control-in-Asp-Net/

[2] https://asp.net-tutorials.com/validation/required-field-validator/

[3] http://www.java2s.com/Tutorial/ASP.NET/0160__Validation/UseaspRangeValidatortocheckthevaluerangeinanasptextbox.htm

[4] http://www.informit.com/articles/article.aspx?p=101137&seqNum=5

[5] https://learn.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.rangevalidator.minimumvalue?view=netframework-4.8

[6] https://www.tutorialspoint.com/asp.net/asp.net_validators.htm

Here is an example of one of the FormViews that I am trying to validate. In the RangeValidator I just have hard coded Max and Min values but I eventually want to have the Min value to be the same value that is in the begin date text box plus day:

      <asp:FormView ID="fvNotification" runat="server" Visible="False" DefaultMode="Insert" GridLines="Both" DataSourceID="SqlUserDetails">
           <InsertItemTemplate>
                 <asp:Table ID="Table1" runat="server">
                   <asp:TableHeaderRow>
                       <asp:TableHeaderCell>Notification</asp:TableHeaderCell>
                       <asp:TableHeaderCell>Filter 1</asp:TableHeaderCell>
                       <asp:TableHeaderCell>Filter 2</asp:TableHeaderCell>
                       <asp:TableHeaderCell>Begin Date</asp:TableHeaderCell>
                       <asp:TableHeaderCell>End Date</asp:TableHeaderCell>
                   </asp:TableHeaderRow>
                   <asp:TableRow>
                       <asp:TableCell>
                           <asp:DropDownList ID="ddNotification" runat="server" DataSourceID="SqlNotifications" DataTextField="Name" DataValueField="Name" ></asp:DropDownList></asp:TableCell>
                       <asp:TableCell>
                           <asp:DropDownList ID="ddFilterInsrt" runat="server" DataSourceID="SqlFilters1" DataTextField="Filter" DataValueField="Filter" ></asp:DropDownList></asp:TableCell>
                       <asp:TableCell>
                           <asp:DropDownList ID="ddFilterInsrt2 runat="server" >
                                <asp:ListItem>*</asp:ListItem>
                                <asp:ListItem>A</asp:ListItem>
                                <asp:ListItem>B</asp:ListItem>
                                <asp:ListItem>C</asp:ListItem>
                                <asp:ListItem>D</asp:ListItem>
                           </asp:DropDownList>
                       </asp:TableCell>
                     <asp:TableCell>
                         <asp:TextBox ID="TextBoxDateBgnInsrt" runat="server" autocomplete="Disabled" ></asp:TextBox>
                         <ajaxToolkit:CalendarExtender runat="server" BehaviorID="TextBoxDateBgnInsrt_CalendarExtender" TargetControlID="TextBoxDateBgnInsrt" ID="TextBoxDateBgnInsrt_CalendarExtender"></ajaxToolkit:CalendarExtender>
                       </asp:TableCell>
                       <asp:TableCell>
                           <asp:TextBox ID="TextBoxDateEndInsrt" runat="server" autocomplete="Disabled" ></asp:TextBox>
                           <ajaxToolkit:CalendarExtender runat="server" BehaviorID="TextBoxDateEndInsrt_CalendarExtender" TargetControlID="TextBoxDateEndInsrt" ID="TextBoxDateEndInsrt_CalendarExtender"></ajaxToolkit:CalendarExtender>
                           <asp:RangeValidator  runat="server" id="rngDate" controltovalidate="TextBoxDateEndInsrt" type="Date" MaximumValue='09/20/2011' MinimumValue="09/01/2011" errormessage="Please enter a valid date within 2006!" display="Dynamic"/>
                       </asp:TableCell>

                 </asp:TableRow>
               </asp:Table>
               <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" CausesValidation="True" />
             &nbsp;<asp:Button ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" OnClick="InsertCancelButton_Click1" />
               &nbsp;<asp:Button ID="InsertClearEndDateButton" runat="server" Text="Clear End Date" OnClick="InsertClearEndDateButton_Click"/>

            </InsertItemTemplate>

        </asp:FormView>

I am expecting the FormView to be visible and validate after clicking the button that make the FormView visible but instead I am getting a 500 error.

0

There are 0 best solutions below