Question
December 13, 2006 at 06:23 AM
ydobonmai

Validating multiple textboxes

by ydobonmai . Updated 19 years, 10 months ago

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

This discussion is locked

All Comments