Solved

Compare Validator:  Using Dateadd to compare dates in c#

Posted on 2009-05-18
2
481 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
2 Comments
 
LVL 18

Accepted Solution

by:
carlnorrbom earned 500 total points
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now