arneweise77
Programmer
Hi!
I create a few textboxes dynamically and then adds it in a placeholder. Works fine. Then the user fills the textboxes and hits a submit-button and here´s my problem. I can´t retrieve the text from the textboxes because the textboxes doesn´t seem to exist anymore!? How can that be?
If I try like PlaceHolder1.Controls.Count() I get zero controls. Here´s the code:
Dim tBox As New TextBox()
Dim lLabel As New Label()
Dim RFValidator As New RequiredFieldValidator()
Dim RValidator As New RangeValidator()
'Some code for the controls
HoursTextBoxPlaceHolder.Controls.Add(tBox)
HoursTextBoxPlaceHolder.Controls.Add(lLabel)
HoursTextBoxPlaceHolder.Controls.Add(RFValidator)
HoursTextBoxPlaceHolder.Controls.Add(RValidator)
And then:
For i=0 to HoursTextBoxPlaceHolder.Controls.Count() - 1
If HoursTextBoxPlaceHolder.Controls(i).GetType().ToString().Equals("System.Web.UI.WebControls.TextBox"
Then
dim str = CType(HoursTextBoxPlaceHolder.Controls(i), TextBox).Text
End If
Next
I create a few textboxes dynamically and then adds it in a placeholder. Works fine. Then the user fills the textboxes and hits a submit-button and here´s my problem. I can´t retrieve the text from the textboxes because the textboxes doesn´t seem to exist anymore!? How can that be?
If I try like PlaceHolder1.Controls.Count() I get zero controls. Here´s the code:
Dim tBox As New TextBox()
Dim lLabel As New Label()
Dim RFValidator As New RequiredFieldValidator()
Dim RValidator As New RangeValidator()
'Some code for the controls
HoursTextBoxPlaceHolder.Controls.Add(tBox)
HoursTextBoxPlaceHolder.Controls.Add(lLabel)
HoursTextBoxPlaceHolder.Controls.Add(RFValidator)
HoursTextBoxPlaceHolder.Controls.Add(RValidator)
And then:
For i=0 to HoursTextBoxPlaceHolder.Controls.Count() - 1
If HoursTextBoxPlaceHolder.Controls(i).GetType().ToString().Equals("System.Web.UI.WebControls.TextBox"
dim str = CType(HoursTextBoxPlaceHolder.Controls(i), TextBox).Text
End If
Next