title: Grabbing user's textbox input from dynamically created textboxes
body: <p>I am using Visual Studio with asp.net, vb.net, and webforms.</p>
  <p>My issue is that I need to get the user's textbox input from my dynamically generated textboxes.</p>
  <p>On my button click BtnStep4Next, I dynamically add ServiceForm.ascx (it is a form with FirstName, LastName, City, etc). I add the Service Form to a list, and the list is stored in a session. There could be, for example, 5 webforms (ServiceForm).</p>
  <pre><code>Protected Sub BtnStep4Next_Click(sender As Object, e As EventArgs) Handles BtnStep4Next.Click
  
      Dim formCount As Integer = 0
  
      'Create a list to hold all of the service forms
      Dim listServiceForms As New List(Of openapps_luesreg_ServiceForm)
      Session(&quot;vsServiceForms&quot;) = listServiceForms
  
      For Each i In CBLModifications.Items
          'Do not show a service form for membership (ID = 1)
          If i.Value &lt;&gt; &quot;1&quot; Then
              formCount += 1
  
              Dim serviceForm As openapps_luesreg_ServiceForm = New openapps_luesreg_ServiceForm()
  
              'Load a new Service Form to the page
              serviceForm = Page.LoadControl(&quot;ServiceForm.ascx&quot;)
              serviceForm.ID = &quot;service&quot; + formCount.ToString
  
              Dim txtCity As TextBox = CType(serviceForm.FindControl(&quot;txtCity&quot;), TextBox)
              txtCity.ID = &quot;serviceCity&quot; + formCount.ToString
  
              'Dim txtCityRegEx As Regex = CType(serviceForm.FindControl(&quot;RegExCity&quot;), Regex)
              'txtCityRegEx.ID = &quot;serviceCity&quot; + formCount.ToString
  
  
              'Add the new Service Form to the panel PnlService Forms
              PnlServiceForms.Controls.Add(serviceForm)
  
              'Add the name to the top of the Form
              Dim lblServiceName As Label = CType(serviceForm.FindControl(&quot;lblServiceName&quot;), Label)
              lblServiceName.Text = i.Text
  
              'Add to listServiceForms
              listServiceForms.Add(serviceForm)
  
              'Set the list to the ViewState
              Session(&quot;vsServiceForms&quot;) = listServiceForms
  
          End If
      Next
   End Sub
  </code></pre>
  <p>On a different button click, now I want to grab the user's input they type into the textboxes. My code here though results in empty strings (the original form text) instead of the user's updated input. How can I actually get each textboxes' text that the user enters at this point?</p>
  <pre><code>Protected Sub BtnStep5Next_Click(sender As Object, e As EventArgs) Handles BtnStep5Next.Click
  
  
      Dim listServiceForms As List(Of openapps_luesreg_ServiceForm)
      listServiceForms = DirectCast(Session(&quot;vsServiceForms&quot;), List(Of openapps_luesreg_ServiceForm))
  
      Dim myCount As Integer = 0
      For Each i In listServiceForms
          myCount += 1
          Dim ctlTxtCity As String = &quot;serviceCity&quot; + myCount.ToString
  
          Dim myCity2 = ctlTxtCity
  
          Dim txtNewCity As TextBox =  CType(i.FindControl(ctlTxtCity), TextBox)
          Dim myCity = txtNewCity.Text
  
      Next
  End Sub
  </code></pre>