Solved

Compare Validator:  Using Dateadd to compare dates in c#

Posted on 2009-05-18
2
497 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 500 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

696 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