Link to home
Start Free TrialLog in
Avatar of devnewbee
devnewbee

asked on

Compare Validator: Using Dateadd to compare dates in c#

I have the following code working in VB.

How can I achieve the same in c#?
<asp:CompareValidator ID="Check14DayRule" runat="server" ControlToValidate="txtStartDate"
                                    ValueToCompare='<%# DateAdd(DateInterval.Day, 14, Now()).ToString("MM/dd/yyyy") %>'
                                    ErrorMessage="The training must be more than 14 days away" Display="None" Type="Date"
                                    Operator="GreaterThanEqual" EnableClientScript="False"></asp:CompareValidator>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of carlnorrbom
carlnorrbom
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of devnewbee
devnewbee

ASKER

Actually, I am using this code on a vb app.  If I take it over to a c# app, that is when I run into problems.

The error I get is:

CS0103: The name 'DateAdd' does not exist in the current context