electrosaurus Posted August 13, 2003 Posted August 13, 2003 Im using a compare validator to make sure the date entered is greater than today.. I have the exact same code (below) on two different aspx pages.. One works ... one doesn't.. . The CompareValidator that works is contained in an EditItemTemplate of a DataGrid were as the comparevalidator that isnt working is just on a page. Any ideas why this isnt working?? Or know a better way to accomplish this? Thanks! <asp:CompareValidator id=cvalEditExpiry runat="server" ErrorMessage="Expiry date must be greater than today in MM/DD/YYYY format" Display="None" ControlToValidate="txtEditExpiry" Type="Date" Operator="GreaterThanEqual" ValueToCompare="<%# DateTime.Today.ToShortDateString() %>"> </asp:CompareValidator> Heres the error message. The value '' of the ValueToCompare property of 'cvalExpiry' cannot be converted to type 'Date'. Quote
Moderators Robby Posted August 14, 2003 Moderators Posted August 14, 2003 You made the validator type="Date" but the DateTime.Today.ToShortDateString is a string. Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.