zimmer9
asked on
How to ensure the Validator keeps sending back an error message from an ASP.NET application using C# with VS2010?
I am developing an ASP.NET application in C# using VS2010.
I use a gridview and within the grid, I validate an input date field titled "txtchkDt".
If the user inputs a date into this field in the format "CCYY/MM/DD", the RegularExpressionValidator sends back the error message: "Date must be in the format of MM/DD/YYYY"
After the user inputs this value, I have an link in the last column that the user clicks on to update the record.
So if the user clicks on the link for the first time, the error message is generated.
However, if the user doesn't change the date entered in the format "CCYY/MM/DD and clicks on the link to update a 2nd time,
the Validator doesn't resend the error message and the application jumps into the event, gridview_RowUpdating.
Do you know how I can ensure that the application will keep sending back the error message from the Validator until the user enters the date in the format "MM/DD/YYYY"?
<EditItemTemplate>
<asp:TextBox ID="txtchkDt" runat="server" Text='<%# Eval("chkDt") %>'></asp:TextBox>
<asp:CompareValidator ID="DateValidator1" runat="server" Operator="DataTypeCheck"
Type="Date" ControlToValidate="txtchkD t" ErrorMessage="Please enter a valid start
date mm/dd/yyyy" />
<asp:RequiredFieldValidato r ID="RequiredFieldValidator 2" runat="server" ControlToValidate="txtchkD t" Display="Dynamic" ErrorMessage="Date is required" ValidationGroup="AllValida tors">*</a sp:Require dFieldVali dator>
<asp:RegularExpressionVali dator ID="RegularExpressionValid ator2" runat="server" ControlToValidate="txtchkD t" Display="Dynamic" ErrorMessage="Date must be in the format of MM/DD/YYYY" ValidationGroup="AllValida tors" ValidationExpression="^(0? [1-9]|1[0- 2])\/(0?[1 -9]|1\d|2\ d|3[01])\/ (19|20)\d{ 2}" ForeColor="#FF0066"></asp: RegularExp ressionVal idator>
</EditItemTemplate>
I use a gridview and within the grid, I validate an input date field titled "txtchkDt".
If the user inputs a date into this field in the format "CCYY/MM/DD", the RegularExpressionValidator
After the user inputs this value, I have an link in the last column that the user clicks on to update the record.
So if the user clicks on the link for the first time, the error message is generated.
However, if the user doesn't change the date entered in the format "CCYY/MM/DD and clicks on the link to update a 2nd time,
the Validator doesn't resend the error message and the application jumps into the event, gridview_RowUpdating.
Do you know how I can ensure that the application will keep sending back the error message from the Validator until the user enters the date in the format "MM/DD/YYYY"?
<EditItemTemplate>
<asp:TextBox ID="txtchkDt" runat="server" Text='<%# Eval("chkDt") %>'></asp:TextBox>
<asp:CompareValidator ID="DateValidator1" runat="server" Operator="DataTypeCheck"
Type="Date" ControlToValidate="txtchkD
date mm/dd/yyyy" />
<asp:RequiredFieldValidato
<asp:RegularExpressionVali
</EditItemTemplate>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.