Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieve text from dynamic textbox

Status
Not open for further replies.

arneweise77

Programmer
Apr 25, 2002
46
SE
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top