?
Solved

Compare Validator:  Using Dateadd to compare dates in c#

Posted on 2009-05-18
2
Medium Priority
?
505 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

752 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