Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Compare Validator:  Using Dateadd to compare dates in c#

Posted on 2009-05-18
2
Medium Priority
?
511 Views
Last Modified: 2013-11-08
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

0
Comment
Question by:devnewbee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 18

Accepted Solution

by:
carlnorrbom earned 1000 total points
ID: 24412990
Hi,
As far as I can see it should work without any changes? If the page is using a vb code behind file and you want to change it to C#, simply add a new code behind file "pagename.aspx.cs" and change the page declaration to reflect it's C# rather than VB and change the name of the code behind file.
/Carl.
0
 

Author Comment

by:devnewbee
ID: 24413090
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
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

598 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question