My apologies if this has been asked and please point me in the right direction if so.
I need to add code where enterDate cannot be greater than currentDate, then validate, "future date cannot be entered". My code is all under the public bool Save() but did not think I needed to create a constructor to add some Datetime code.
Public Bool Save()
....Existing code here....
ValidationResults results = newValidationResults(); //this was already used in
a prior code under public bool Save() so I reuse below
DateTime? enterDate = tbEnterDate.NullableDate;
DateTime? CurrentDate = DateTime.Today;
if (enterDate > CurrentDate)
{
ValidationResult vr2 =
newValidationResult("Future
date cannot be entered"); //ValidationResult vr1 has already been used.
results.AddResult(vr2);
returnfalse;
}
else
{
if (enterDate ==
DateTime.Today)
{
return CurrentDate
== DateTime.Today;
}
}
Error points to my ValidationResult. Do I need create a whole new validation for this? Thank you.
newdotnetter
0 Points
8 Posts
Error: Validation.ValidationResult does not contain a constructor that takes 1 argument
Nov 23, 2012 07:37 PM|LINK
My apologies if this has been asked and please point me in the right direction if so.
I need to add code where enterDate cannot be greater than currentDate, then validate, "future date cannot be entered". My code is all under the public bool Save() but did not think I needed to create a constructor to add some Datetime code.
Public Bool Save()
....Existing code here....
ValidationResults results = new ValidationResults(); //this was already used in a prior code under public bool Save() so I reuse below
DateTime? enterDate = tbEnterDate.NullableDate;
DateTime? CurrentDate = DateTime.Today;
if (enterDate > CurrentDate)
{
ValidationResult vr2 = new ValidationResult("Future date cannot be entered"); //ValidationResult vr1 has already been used.
results.AddResult(vr2);
return false;
}
else
{
if (enterDate == DateTime.Today)
{
return CurrentDate == DateTime.Today;
}
}
Error points to my ValidationResult. Do I need create a whole new validation for this? Thank you.
oned_gk
All-Star
31762 Points
6490 Posts
Re: Error: Validation.ValidationResult does not contain a constructor that takes 1 argument
Nov 23, 2012 09:59 PM|LINK
Use comparevalidator