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
"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