Hello,
I have a lot of textboxes on a Form and want to create a ControlCollection.
Here is my code:
Protected WithEvents textBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents textBox2 As System.Web.UI.WebControls.TextBox
Protected WithEvents txtCol As System.Web.UI.Control
Protected WithEvents revtxtBox As System.Web.UI.WebControls.RegularExpressionValidator
Dim txtCol As New System.Web.UI.Control()
Dim ctl As New ControlCollection(txtCol)
Dim revtxtBox As New System.Web.UI.WebControls.RegularExpressionValidator()
ctl.Add(textBox1)
ctl.Add(textBox2)
For Each txtCol In ctl
revtxtBox.ControlToValidate = txtCol.ID
revtxtBox.ValidationExpression = "\w{4}"
revtxtBox.ErrorMessage = "test"
Next
I got no error message but TextBox1 and TextBox2 disappear from my Form.
Can anybody help me to find why ?
Many thanks.
I have a lot of textboxes on a Form and want to create a ControlCollection.
Here is my code:
Protected WithEvents textBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents textBox2 As System.Web.UI.WebControls.TextBox
Protected WithEvents txtCol As System.Web.UI.Control
Protected WithEvents revtxtBox As System.Web.UI.WebControls.RegularExpressionValidator
Dim txtCol As New System.Web.UI.Control()
Dim ctl As New ControlCollection(txtCol)
Dim revtxtBox As New System.Web.UI.WebControls.RegularExpressionValidator()
ctl.Add(textBox1)
ctl.Add(textBox2)
For Each txtCol In ctl
revtxtBox.ControlToValidate = txtCol.ID
revtxtBox.ValidationExpression = "\w{4}"
revtxtBox.ErrorMessage = "test"
Next
I got no error message but TextBox1 and TextBox2 disappear from my Form.
Can anybody help me to find why ?
Many thanks.