Question Locked

Validating multiple textboxes

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have this page with about 40 text boxes and need to validate all of the to ensure that no box is left blank and that all values are between 1 and 100. I have the idea of using 80 validation controls to do this (I have 7 such pages which means 80*7). Is there any way I could do this programmatically. I tried using the following code but it does not work:

For Each txt In Page.Items

TextBox1.Text = txt.ID

Dim rfv As New RequiredFieldValidator()

rfv.ID = txt.ID

rfv.ControlToValidate = txt.ID

rfv.ErrorMessage = "Please check errors"

Page.Controls.Add(rfv)

rfv.Validate()

Next

Any Ideas?

Please help. I am desperate.

Thanks

1 reply

This discussion is closed to new replies.