G
GOKU24
Framework: Version: 1.1
Language: VB.NET
Platform: Win 2K Pro
I need to validate dynamically created textboxes. The validation
controls are created at design time. The created Textbox is being
added to a Placeholder.
When I try to submit the page I get the following error:
Unable to find control id 'xxx' referenced by the 'ControlToValidate'
property of 'xxx'.
The textboxes are created on Page_Load. I've also tried creating them
on Page_Init, but I get the same error. A sample of the code is
below.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
EnableDisableTextboxes(strOne)
End If
End Sub
'Sub that creates Textbox at Run-Time
Public Sub EnableDisableTextboxes(ByVal strOne As String)
If X <= Y Then
Dim lblOne As New Label
lblOne.Text = strOne
plhOne.Controls.Add(lblOne)
Else
Dim txtOne As New TextBox
txtOne.TextMode = TextBoxMode.SingleLine
txtOne.Text = strOne
txtOne.ID = "txtOne"
plhOne.Controls.Add(txtOne)
regexOne.Visible = True
End If
End Sub
'Sample Validation code created at Design Time
<asp:regularexpressionvalidator id="regexOne" Runat="server"
ValidationExpression="XXXX" Display="None" ErrorMessage="Error
Message" Enabled="True" ControlToValidate="txtOne" Visible="False" />
Any help would be appreciated. Thanks in advance.
-T
Language: VB.NET
Platform: Win 2K Pro
I need to validate dynamically created textboxes. The validation
controls are created at design time. The created Textbox is being
added to a Placeholder.
When I try to submit the page I get the following error:
Unable to find control id 'xxx' referenced by the 'ControlToValidate'
property of 'xxx'.
The textboxes are created on Page_Load. I've also tried creating them
on Page_Init, but I get the same error. A sample of the code is
below.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
EnableDisableTextboxes(strOne)
End If
End Sub
'Sub that creates Textbox at Run-Time
Public Sub EnableDisableTextboxes(ByVal strOne As String)
If X <= Y Then
Dim lblOne As New Label
lblOne.Text = strOne
plhOne.Controls.Add(lblOne)
Else
Dim txtOne As New TextBox
txtOne.TextMode = TextBoxMode.SingleLine
txtOne.Text = strOne
txtOne.ID = "txtOne"
plhOne.Controls.Add(txtOne)
regexOne.Visible = True
End If
End Sub
'Sample Validation code created at Design Time
<asp:regularexpressionvalidator id="regexOne" Runat="server"
ValidationExpression="XXXX" Display="None" ErrorMessage="Error
Message" Enabled="True" ControlToValidate="txtOne" Visible="False" />
Any help would be appreciated. Thanks in advance.
-T