adding validation controls

W

wellery

I'm trying to work out how to do this. So far I keep getting errors
"Unable to find control ID..."

What I've got is a datefield control which draws a calendar popup and a
text field. I draw two of these date fields on a page by adding them to
the controls collection. The dates work fine however I want to add
validation to them to ensure the first date is less than the second
date but this isn't working. So far I'm doing this:

//creat objects
CompareValidator objCompareDateVal = new CompareValidator();
PUDateField objStartDateField = new PUDateField("StartDate);
PUDateField objEndDateField = new PUDateField("EndDate);

//setup compare validator
objCompareDateVal.Operator = ValidationCompareOperator.LessThanEqual;
objCompareDateVal.ControlToValidate = objStartDateField.ID;
objCompareDateVal.ControlToCompare = objEndDateField.ID;

//add the controls
this.Controls.Add(objStartDateField);
this.Controls.Add(objEndDateField);
this.Controls.Add(objCompareDateVal);

In the date field I also used:

[ValidationPropertyAttribute("Value")]

public string Value
{
get
{
return this._objTextBox.Value;
}
set
{
_objTextBox.Value = value;
}
}

I'm not sure If I'm doing this the right way. Can someone please point
me in the right direction on how I should accomplish what I'm trying to
do? Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,265
Messages
2,571,069
Members
48,771
Latest member
ElysaD

Latest Threads

Top