I am trying to perform some custom validation in a text field if a particular value is selected from a drop down list.
The fields (that matter) in the form are
Source
- Allow Empty Value = false
- Form Control = Drop down list
OtherSource
- Allow Empty Value = true
- Form Control = Text box
If the value "other" is selected in Source i want to make OtherSource required
The problem is that Other Source does not have a FieldErrorLabels defined and when i add one it is not being displayed.
I have cloned bizform.ascx
protected void SetupControl()
{
//...
viewBiz.OnBeforeValidate += viewBiz_OnBeforeValidate;
//...
}
void viewBiz_OnBeforeValidate(object sender, EventArgs e)
{
var errorLabel = new LocalizedLabel();
errorLabel.Text = "Please enter Other Source value.";
errorLabel.Visible = true;
ViewBiz.BasicForm.FieldErrorLabels.Add("OtherSource", errorLabel);
ViewBiz.ValidationErrorMessage = "just show me something";
ViewBiz.StopProcessing = true;
}
Why cant i get the error label for OtherSource to show?