G
Guest
I have a form where I create dynamic controls at runtime. With this, I am
adding a dynamic required field validators to each control as needed, but the
validators are not firing when I click submit. The submit button was placed
at design time and its causesvalidation property is set to true. Can someone
tell me what is missing that will make the validator fire client side? Thank
you.
1. Code to add dynamic control works fine and I get the Id of the textbox
control
2. Then I see if a validator is required and add it...code below for that.
3. I have the validator display set to none because I have a validation
summary control, placed at design time, that I want to display. Is there
something I need to do to make the validation summary know the required field
validator is there?
if (required)
{
RequiredFieldValidator validator = new RequiredFieldValidator();
validator.ID = "validator" + controlCount.ToString();
validator.ControlToValidate = textBox.ID;
validator.ErrorMessage = "Please fill out the textbox ";
validator.Display = ValidatorDisplay.None;
phContainer.Controls.Add(validator);
}
adding a dynamic required field validators to each control as needed, but the
validators are not firing when I click submit. The submit button was placed
at design time and its causesvalidation property is set to true. Can someone
tell me what is missing that will make the validator fire client side? Thank
you.
1. Code to add dynamic control works fine and I get the Id of the textbox
control
2. Then I see if a validator is required and add it...code below for that.
3. I have the validator display set to none because I have a validation
summary control, placed at design time, that I want to display. Is there
something I need to do to make the validation summary know the required field
validator is there?
if (required)
{
RequiredFieldValidator validator = new RequiredFieldValidator();
validator.ID = "validator" + controlCount.ToString();
validator.ControlToValidate = textBox.ID;
validator.ErrorMessage = "Please fill out the textbox ";
validator.Display = ValidatorDisplay.None;
phContainer.Controls.Add(validator);
}